use asByteBuffer() in the CatRank benchmark

This commit is contained in:
David Renshaw 2014-10-13 20:29:24 -04:00
parent 9e0bd28c60
commit 6764cc2449

View file

@ -62,15 +62,14 @@ public class CatRank
int urlSize = rng.nextLessThan(100); int urlSize = rng.nextLessThan(100);
int urlPrefixLength = URL_PREFIX.size(); int urlPrefixLength = URL_PREFIX.size();
StringBuilder url = new StringBuilder(); Text.Builder url = result.initUrl(urlSize + urlPrefixLength);
url.append(URL_PREFIX); java.nio.ByteBuffer bytes = url.asByteBuffer();
bytes.put(URL_PREFIX.asByteBuffer());
for (int j = 0; j < urlSize; j++) { for (int j = 0; j < urlSize; j++) {
url.append('a' + rng.nextLessThan(26)); bytes.put((byte) (97 + rng.nextLessThan(26)));
} }
result.setUrl(url.toString());
boolean isCat = rng.nextLessThan(8) == 0; boolean isCat = rng.nextLessThan(8) == 0;
boolean isDog = rng.nextLessThan(8) == 0; boolean isDog = rng.nextLessThan(8) == 0;
if (isCat && !isDog) { if (isCat && !isDog) {