Skip to content

Profiler

landawn edited this page Apr 29, 2018 · 1 revision

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

, |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,

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