#171 Redis与MongoDB的Benchmark测试用例,some renaming.

This commit is contained in:
Calvin
2013-01-18 00:09:05 +08:00
parent 605c66c33e
commit 13a85bf5f9
4 changed files with 10 additions and 9 deletions
@@ -30,7 +30,7 @@ public class MongoJavaDriverBenchmark extends BenchmarkBase {
}
@Override
protected void onPrepare() {
protected void onStart() {
Mongo mongoClient = null;
try {
mongoClient = new Mongo(host);
@@ -32,7 +32,7 @@ public class MongoSpringDataBenchmark extends BenchmarkBase {
}
@Override
protected void onPrepare() {
protected void onStart() {
try {
Mongo client = new Mongo(host);
client.setWriteConcern(WriteConcern.SAFE);
@@ -23,7 +23,7 @@ public class RedisJedisBenchmark extends BenchmarkBase {
}
@Override
protected void onPrepare() {
protected void onStart() {
//reset counter
Jedis jedis = new Jedis(host);
jedis.set(counterName, "0");
@@ -22,7 +22,7 @@ public abstract class BenchmarkBase {
}
public void run() throws Exception {
onPrepare();
onStart();
//start threads
ExecutorService threadPool = Executors.newFixedThreadPool(threadCount);
@@ -40,11 +40,13 @@ public abstract class BenchmarkBase {
finishLock.await();
long timeInMills = new Date().getTime() - startTime.getTime();
long totalTimes = threadCount * loopCount;
long invokeTimes = threadCount * loopCount;
System.out.printf("Thread count is %d, Spend %d ms for %d request, TPS is %d\n", threadCount, timeInMills,
totalTimes, (totalTimes * 1000 / timeInMills));
invokeTimes, (invokeTimes * 1000 / timeInMills));
threadPool.shutdownNow();
onFinish();
}
protected Date onThreadStart() {
@@ -67,13 +69,12 @@ public abstract class BenchmarkBase {
System.out.println("Thread average latency " + latency + "ms");
}
protected void onPrepare() {
protected void onStart() {
}
protected void onFinish() {
}
abstract protected Runnable getTask();
}