Java performance timing library

dfa picture dfa · Aug 6, 2009 · Viewed 16.1k times · Source

I frequent wrap code in a System.nanoTime() pair in order to timing it. Something like:

long start = System.nanoTime();    
methodToBeTimed();
long elapsedTime = System.nanoTime() - start;

There is any good timing library that helps with this problem? Also homegrown code will be accepted.

NB

A profiler is not a solution here, since I want to enforce some time constraints in my unit tests, so I want to timing methods programmatically.

Answer

Mark picture Mark · Aug 6, 2009

Ignore this answer as the project is no longer active

I haven't used it but I came across perf4j recently.