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.