AbacusUtil Docs | Download | Javadoc | FAQ | Community

Profiler

Profiler is a simple utility class for method performance test

Profiler.run(threadNum, loopNum, repeatNum, "yourMethod", () -> {
    /* call your method */}).printResult();

// call by method.
Profiler.run(instance, "yourMethod", threadNum, loopNum, repeatNum).printResult();

//call by Runnable and write result to Console with html format
Profiler.run(threadNum, loopNum, repeatNum, () -> {
    /* call your method */}).writeHtmlResult(System.out);

//call by method and write result to Console with html format
Profiler.run(instance, "yourMethod", threadNum, loopNum, repeatNum).writeHtmlResult(System.out);

Here is the result with plain text format:

========================================================================================================================
(unit: milliseconds)
threadNum=16; loops=100000
totalElapsedTime: 2258


<method name>,  |avg time|, |min time|, |max time|, |0.01% >=|, |0.1% >=|,  |1% >=|,    |10% >=|,   |20% >=|,   |50% >=|,   |80% >=|,   |90% >=|,   |99% >=|,   |99.9% >=|, |99.99% >=|
yourMethod,      0.0109,     0,          126,        1,          1,          0,          0,          0,          0,          0,          0,          0,          0,          0,          

========================================================================================================================

Here is the result with html format:

========================================================================================================================
(unit: milliseconds)
threadNum=16; loops=100000
totalElapsedTime: 2172

method name avg time min time max time 0.01% >= 0.1% >= 1% >= 10% >= 20% >= 50% >= 80% >= 90% >= 99% >= 99.9% >= 99.99% >=
yourMethod 0.0103 0 130 1 1 0 0 0 0 0 0 0 0 0
========================================================================================================================