From 700ce241067ee0c5ad56587a12218296bf2750cf Mon Sep 17 00:00:00 2001 From: xvrl Date: Mon, 7 Jan 2013 16:52:57 -0800 Subject: [PATCH] fix JVM optimizing out the benchmarking code --- .../druid/client/cache/MemcachedCacheBrokerBenchmark.java | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/client/src/test/java/com/metamx/druid/client/cache/MemcachedCacheBrokerBenchmark.java b/client/src/test/java/com/metamx/druid/client/cache/MemcachedCacheBrokerBenchmark.java index 2fa7d3b4193..d1839098e8b 100644 --- a/client/src/test/java/com/metamx/druid/client/cache/MemcachedCacheBrokerBenchmark.java +++ b/client/src/test/java/com/metamx/druid/client/cache/MemcachedCacheBrokerBenchmark.java @@ -56,7 +56,7 @@ public class MemcachedCacheBrokerBenchmark extends SimpleBenchmark broker = new MemcachedCacheBroker( client, 500, // 500 milliseconds - 3600 * 24 * 365 // 1 year + 3600 // 1 hour ); cache = broker.provideCache("default"); @@ -84,15 +84,17 @@ public class MemcachedCacheBrokerBenchmark extends SimpleBenchmark } } - public byte[] timeGetObject(int reps) { + public long timeGetObject(int reps) { byte[] bytes = null; + long count = 0; for (int i = 0; i < reps; i++) { for(int k = 0; k < objectCount; ++k) { String key = BASE_KEY + i; bytes = cache.get(key.getBytes()); + count += bytes.length; } } - return bytes; + return count; } public static void main(String[] args) throws Exception {