Package org.graylog2.utilities
Class TimedBlock
java.lang.Object
org.graylog2.utilities.TimedBlock
- All Implemented Interfaces:
AutoCloseable
Helper to time arbitrary blocks of Java code, especially useful for coarse one-off performance testing.
This is not intended to be a silver bullet, but certainly more convenient than adding stopwatches all over the place.
Use it like this:
try (TimedBlock ignored = TimedBlock.timed("myBlock").aboveMillis(100).start()) { // code to time, will only print timing info if it took 100ms or more }By default it will use its own logger to write timing information after the try-with-resources block exits.
-
Nested Class Summary
-
Method Summary
-
Method Details
-
timed
-
start
-
close
public void close()- Specified by:
close
in interfaceAutoCloseable
-