Disabled logging in JedisPool benchmark
This commit is contained in:
@@ -6,11 +6,14 @@ import java.util.ArrayList;
|
|||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.concurrent.TimeoutException;
|
import java.util.concurrent.TimeoutException;
|
||||||
import java.util.concurrent.atomic.AtomicInteger;
|
import java.util.concurrent.atomic.AtomicInteger;
|
||||||
|
import java.util.logging.Level;
|
||||||
|
import java.util.logging.Logger;
|
||||||
|
|
||||||
import redis.clients.jedis.Jedis;
|
import redis.clients.jedis.Jedis;
|
||||||
import redis.clients.jedis.JedisPool;
|
import redis.clients.jedis.JedisPool;
|
||||||
import redis.clients.jedis.tests.HostAndPortUtil;
|
import redis.clients.jedis.tests.HostAndPortUtil;
|
||||||
import redis.clients.jedis.tests.HostAndPortUtil.HostAndPort;
|
import redis.clients.jedis.tests.HostAndPortUtil.HostAndPort;
|
||||||
|
import redis.clients.util.FixedResourcePool;
|
||||||
|
|
||||||
public class PoolBenchmark {
|
public class PoolBenchmark {
|
||||||
private static HostAndPort hnp = HostAndPortUtil.getRedisServers().get(0);
|
private static HostAndPort hnp = HostAndPortUtil.getRedisServers().get(0);
|
||||||
@@ -18,6 +21,9 @@ public class PoolBenchmark {
|
|||||||
|
|
||||||
public static void main(String[] args) throws UnknownHostException,
|
public static void main(String[] args) throws UnknownHostException,
|
||||||
IOException, TimeoutException, InterruptedException {
|
IOException, TimeoutException, InterruptedException {
|
||||||
|
Logger logger = Logger.getLogger(FixedResourcePool.class.getName());
|
||||||
|
logger.setLevel(Level.OFF);
|
||||||
|
|
||||||
Jedis j = new Jedis(hnp.host, hnp.port);
|
Jedis j = new Jedis(hnp.host, hnp.port);
|
||||||
j.connect();
|
j.connect();
|
||||||
j.auth("foobared");
|
j.auth("foobared");
|
||||||
@@ -31,40 +37,9 @@ public class PoolBenchmark {
|
|||||||
System.out.println(((1000 * 2 * TOTAL_OPERATIONS) / elapsed) + " ops");
|
System.out.println(((1000 * 2 * TOTAL_OPERATIONS) / elapsed) + " ops");
|
||||||
}
|
}
|
||||||
|
|
||||||
private static void withoutPool() throws InterruptedException {
|
|
||||||
List<Thread> tds = new ArrayList<Thread>();
|
|
||||||
|
|
||||||
for (int i = 0; i < TOTAL_OPERATIONS; i++) {
|
|
||||||
final String key = "foo" + i;
|
|
||||||
Thread hj = new Thread(new Runnable() {
|
|
||||||
@Override
|
|
||||||
public void run() {
|
|
||||||
Jedis j = new Jedis(hnp.host, hnp.port);
|
|
||||||
try {
|
|
||||||
j.connect();
|
|
||||||
j.auth("foobared");
|
|
||||||
j.set(key, key);
|
|
||||||
j.get(key);
|
|
||||||
j.quit();
|
|
||||||
j.disconnect();
|
|
||||||
} catch (UnknownHostException e) {
|
|
||||||
e.printStackTrace();
|
|
||||||
} catch (IOException e) {
|
|
||||||
e.printStackTrace();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
});
|
|
||||||
tds.add(hj);
|
|
||||||
hj.start();
|
|
||||||
}
|
|
||||||
for (Thread thread : tds) {
|
|
||||||
thread.join();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private static void withPool() throws InterruptedException {
|
private static void withPool() throws InterruptedException {
|
||||||
final JedisPool pool = new JedisPool(hnp.host, hnp.port,
|
final JedisPool pool = new JedisPool(hnp.host, hnp.port, 2000,
|
||||||
2000, "foobared");
|
"foobared");
|
||||||
pool.setResourcesNumber(50);
|
pool.setResourcesNumber(50);
|
||||||
pool.setDefaultPoolWait(1000000);
|
pool.setDefaultPoolWait(1000000);
|
||||||
pool.init();
|
pool.init();
|
||||||
|
|||||||
Reference in New Issue
Block a user