From 708ae8a56e92c701b27afb8cfa4417a13bcdf9be Mon Sep 17 00:00:00 2001 From: Jonathan Leibiusky Date: Tue, 14 Sep 2010 14:17:10 -0300 Subject: [PATCH] Fixed small bug in the benchmark test --- .../jedis/tests/benchmark/PoolBenchmark.java | 33 ++++++++++--------- 1 file changed, 17 insertions(+), 16 deletions(-) diff --git a/src/test/java/redis/clients/jedis/tests/benchmark/PoolBenchmark.java b/src/test/java/redis/clients/jedis/tests/benchmark/PoolBenchmark.java index c87d51a..71d9482 100644 --- a/src/test/java/redis/clients/jedis/tests/benchmark/PoolBenchmark.java +++ b/src/test/java/redis/clients/jedis/tests/benchmark/PoolBenchmark.java @@ -25,7 +25,7 @@ public class PoolBenchmark { // withoutPool(); withPool(); long elapsed = System.currentTimeMillis() - t; - System.out.println(((1000 * 2 * TOTAL_OPERATIONS) / elapsed) + " ops"); + System.out.println(((1000 * 3 * TOTAL_OPERATIONS) / elapsed) + " ops"); } private static void withoutPool() throws InterruptedException { @@ -66,30 +66,31 @@ public class PoolBenchmark { pool.init(); List tds = new ArrayList(); - final AtomicInteger ind = new AtomicInteger(); + final AtomicInteger ind = new AtomicInteger(); for (int i = 0; i < 50; i++) { Thread hj = new Thread(new Runnable() { public void run() { - for(int i = 0; (i = ind.getAndIncrement()) < TOTAL_OPERATIONS; ) { - try { - Jedis j = pool.getResource(); - final String key = "foo" + i; - j.set(key, key); - j.get(key); - pool.returnResource(j); - } catch (Exception e) { - e.printStackTrace(); - } - } + for (int i = 0; (i = ind.getAndIncrement()) < TOTAL_OPERATIONS;) { + try { + Jedis j = pool.getResource(); + j.auth("foobared"); + final String key = "foo" + i; + j.set(key, key); + j.get(key); + pool.returnResource(j); + } catch (Exception e) { + e.printStackTrace(); + } + } } }); tds.add(hj); hj.start(); } - for(Thread t : tds) - t.join(); - + for (Thread t : tds) + t.join(); + pool.destroy(); } } \ No newline at end of file