Skip to content

Commit

Permalink
FLogger吞吐量测试
Browse files Browse the repository at this point in the history
  • Loading branch information
cyfonly committed Feb 8, 2017
1 parent 153b275 commit eb60102
Showing 1 changed file with 46 additions and 0 deletions.
46 changes: 46 additions & 0 deletions src/test/java/com/yun/flogger/test/FloggerThroughputTest.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
package com.yun.flogger.test;

import java.util.concurrent.CountDownLatch;

import com.cyfonly.flogger.FLogger;


/**
* FLogger吞吐量测试类
* @author yunfeng.cheng
* @create 2017-02-08
*/
public class FloggerThroughputTest {
private static FLogger flogger = FLogger.getInstance();

private static String record_100_byte = "Performance Testing.Performance Testing.Performance Testing.Performance Testing.Performance Testing."; //100字节
private static String record_200_byte = "Performance Testing.Performance Testing.Performance Testing.Performance Testing.Performance Testing.Performance Testing.Performance Testing.Performance Testing.Performance Testing.Performance Testing."; //200字节
private static String record_400_byte = "Performance Testing.Performance Testing.Performance Testing.Performance Testing.Performance Testing.Performance Testing.Performance Testing.Performance Testing.Performance Testing.Performance Testing.Performance Testing.Performance Testing.Performance Testing.Performance Testing.Performance Testing.Performance Testing.Performance Testing.Performance Testing.Performance Testing.Performance Testing."; //200字节
private static int messageCount = 1000000;
private static int threadNum = 1; //1,2,4,8,16,32

public static void main(String[] args) throws InterruptedException{

final int singleCount = messageCount / threadNum;
final CountDownLatch latch = new CountDownLatch(threadNum);

long st = System.currentTimeMillis();
for(int i=0; i<threadNum; i++){
new Thread(new Runnable() {
@Override
public void run() {
for(int j=0; j<singleCount; j++){
flogger.info(record_400_byte);
}
latch.countDown();
}
}).start();
}
latch.await();
long et = System.currentTimeMillis();

System.out.println("messageCount=" + messageCount + ", threadNum=" + threadNum + ", costTime=" + (et-st) +"ms, throughput=" + (1*1000*messageCount/(et-st)));
System.exit(0);
}

}

0 comments on commit eb60102

Please sign in to comment.