Java performance timing library
问题 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 . 回答1: I haven't used it but I came across perf4j recently. 回答2: