알고리즘에 대한 의견이나 조언을 요청합니다.기본형 캐스팅 대 바이트 형 트리밍
ByteBuffer bb = ByteBuffer.allocate(8);
bb.putLong(rs.getLong(index));//retrieve long from db (unsigned INT)
byte[] tmp = new byte[4];
bb.position(4);
bb.get(tmp);
(Inet4Address) InetAddress.getByAddress(tmp);
대
ByteBuffer bb = ByteBuffer.allocate(4);
bb.putInt((int) rs.getLong(index));//retrieve long from db (unsigned INT)
bb.flip();
byte[] tmp = new byte[4];
bb.get(tmp);
(Inet4Address) InetAddress.getByAddress(tmp);
기본적으로 내가 거기 캐스팅의 성능 차이 또는 더 나은 더 큰 ByteBuffer를 사용하는 것입니다 여부를 알고 싶습니다.
감사합니다, 감사합니다,
마렉
이 두 블록을 메서드로 묶고 여러 테스트를 작성하고 성능을 비교합니다. 정확한 결과를 얻을 수있을 때 다른 사람들의 의견에 의존하는 이유는 무엇입니까? –