@Override protected void work() { for(int i=0; i<reqCnt; i++) { try { jredis.incr (key); } catch (RedisException e) { e.printStackTrace(); } } } };
private void run() throws RedisException { int database = 11; ConnectionSpec connSpec = DefaultConnectionSpec.newSpec("localhost", 6379, database, "jredis".getBytes()); JRedis jredis = new JRedisClient(connSpec); byte[] key = "bench-jredis-pipeline-key".getBytes(); int iters = 100 * 1000; try { cleandb(jredis); } catch (Throwable e) { e.printStackTrace(); return; } for(;;){ Long counter = null; long start = System.nanoTime(); for(int i=0;i<iters; i++){ counter = jredis.incr(key); } long delta_ns = System.nanoTime() - start; long delta_ms = TimeUnit.MILLISECONDS.convert(delta_ns, TimeUnit.NANOSECONDS); float opsrate = iters/delta_ms; System.out.format("counter: %d msec:%d ops/msecs:%f [delta:%d]\n", counter, delta_ms, opsrate, delta_ns); } }
@Override public void run() { final String wkey = "foo" + j; String wvalue = null; for(int i=0; i< opcnt; i++) { try { client.incr(wkey); wvalue = toStr(client.get(wkey)); } catch (RedisException e) { e.printStackTrace(); break; } } System.out.format("%s => %s\n", wkey, wvalue); } });
/** * In a tight loop, we execute a few select * commands that touch the various permutations of * request complexity, and response type, so that * we can pinpoint the bottlenecks and the general * runtime characteristics of the JRedic provider. * @throws RedisException */ public void run () throws RedisException { Log.log("***** JProfileTestCase ****"); // jredis.auth("jredis").ping().flushall(); int iter = 100000; String key = "foostring"; String cntrkey = "foocntr"; String listkey = "foolist"; String setkey = "fooset"; byte[] data = "meow".getBytes(); long start = System.currentTimeMillis(); for(Long j=0L; j<iter; j++) { jredis.incr(cntrkey); jredis.set(key, data); jredis.sadd(setkey, data); jredis.rpush(listkey, data); } long delta = System.currentTimeMillis() - start; float rate = ((float)iter * 1000) / delta; System.out.format("%d iterations | %d msec | %8.2f /sec \n", iter, delta, rate); } }