fix duplicate keys, shutdown gracefully and make sure we check all multiget keys in memcached benchmark

This commit is contained in:
xvrl 2013-01-16 19:18:14 -08:00
parent dcaa77a883
commit 0bacb85a4a
1 changed files with 6 additions and 6 deletions

View File

@ -44,8 +44,6 @@ public class MemcachedCacheBrokerBenchmark extends SimpleBenchmark
// disable compression
transcoder.setCompressionThreshold(Integer.MAX_VALUE);
System.out.println(String.format("Using memcached hosts [%s]", hosts));
client = new MemcachedClient(
new ConnectionFactoryBuilder().setProtocol(ConnectionFactoryBuilder.Protocol.BINARY)
.setHashAlg(DefaultHashAlgorithm.FNV1A_64_HASH)
@ -72,14 +70,13 @@ public class MemcachedCacheBrokerBenchmark extends SimpleBenchmark
@Override
protected void tearDown() throws Exception
{
client.flush();
client.shutdown();
client.shutdown(1, TimeUnit.MINUTES);
}
public void timePutObjects(int reps) {
for(int i = 0; i < reps; ++i) {
for(int k = 0; k < objectCount; ++k) {
String key = BASE_KEY + i;
String key = BASE_KEY + k;
cache.put(IDENTIFIER, key.getBytes(), randBytes);
}
// make sure the write queue is empty
@ -109,7 +106,10 @@ public class MemcachedCacheBrokerBenchmark extends SimpleBenchmark
keys.add(Pair.of(IDENTIFIER, ByteBuffer.wrap(key.getBytes())));
}
Map<Pair<String, ByteBuffer>, byte[]> results = cache.getBulk(keys);
for(byte[] bytes : results.values()) count += bytes.length;
for(Pair<String, ByteBuffer> key : keys) {
byte[] bytes = results.get(key);
count += bytes.length;
}
}
return count;
}