私のアルゴリズムの一部について意見やアドバイスをお願いしたいと思います。プリミティブをキャストするかバイト単位にトリミングするか
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を使用する方がよいかどうかを知っていただきたいと思います。
おかげで、よろしく、
マレク
これら2つのブロックをメソッドに囲み、いくつかのテストを記述してパフォーマンスを比較します。あなたは正確な結果を得ることができるときに他の人の意見に頼るのはなぜですか? –