Fixed small bug in the benchmark test

This commit is contained in:
Jonathan Leibiusky
2010-09-14 14:17:10 -03:00
parent 703244c85e
commit 708ae8a56e

View File

@@ -25,7 +25,7 @@ public class PoolBenchmark {
// withoutPool(); // withoutPool();
withPool(); withPool();
long elapsed = System.currentTimeMillis() - t; 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 { private static void withoutPool() throws InterruptedException {
@@ -70,9 +70,10 @@ public class PoolBenchmark {
for (int i = 0; i < 50; i++) { for (int i = 0; i < 50; i++) {
Thread hj = new Thread(new Runnable() { Thread hj = new Thread(new Runnable() {
public void run() { public void run() {
for(int i = 0; (i = ind.getAndIncrement()) < TOTAL_OPERATIONS; ) { for (int i = 0; (i = ind.getAndIncrement()) < TOTAL_OPERATIONS;) {
try { try {
Jedis j = pool.getResource(); Jedis j = pool.getResource();
j.auth("foobared");
final String key = "foo" + i; final String key = "foo" + i;
j.set(key, key); j.set(key, key);
j.get(key); j.get(key);
@@ -87,7 +88,7 @@ public class PoolBenchmark {
hj.start(); hj.start();
} }
for(Thread t : tds) for (Thread t : tds)
t.join(); t.join();
pool.destroy(); pool.destroy();