Added a small benchmark test with a small performance improvement

This commit is contained in:
Jonathan Leibiusky
2010-08-04 19:58:42 -03:00
parent de107a8991
commit f53c7a1b97
2 changed files with 44 additions and 11 deletions

View File

@@ -0,0 +1,33 @@
package redis.clients.jedis.tests.benchmark;
import java.io.IOException;
import java.net.UnknownHostException;
import java.util.Calendar;
import redis.clients.jedis.Jedis;
import redis.clients.jedis.JedisException;
public class GetSetBenchmark {
private static final int TOTAL_OPERATIONS = 100000;
public static void main(String[] args) throws UnknownHostException,
IOException, JedisException {
Jedis jedis = new Jedis("localhost");
jedis.connect();
jedis.auth("foobared");
long begin = Calendar.getInstance().getTimeInMillis();
for (int n = 0; n <= TOTAL_OPERATIONS; n++) {
String key = "foo" + n;
jedis.set(key, "bar" + n);
jedis.get(key);
}
long elapsed = Calendar.getInstance().getTimeInMillis() - begin;
jedis.disconnect();
System.out.println(((1000 * 2 * TOTAL_OPERATIONS) / elapsed) + " ops");
}
}