forked from cyfonly/FLogger
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
1 changed file
with
46 additions
and
0 deletions.
There are no files selected for viewing
46 changes: 46 additions & 0 deletions
46
src/test/java/com/yun/flogger/test/FloggerThroughputTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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); | ||
} | ||
|
||
} |