public class Microtiming extends Object
Can be used to identify bottlenecks or to analyze system performance to measure the average execution time of different tasks.
Once the microtiming framework is enabled it will be notified by other frameworks as defined tasks are executed.
The execution times are combined and can be queried using getTimings()
.
An example might be an SQL query which is executed in a loop to perform a file import. Since the SQL-Query is always the same (in case or a prepared statement) the execution times will be added to an average which will be stored until the next call to Microtiming.getTimings().
Modifier and Type | Class and Description |
---|---|
static class |
Microtiming.Timing
Simple value class which represents a measured timing.
|
Modifier and Type | Method and Description |
---|---|
static long |
getLastReset()
Returns the timestamp of the last reset
|
static List<Microtiming.Timing> |
getTimings()
Returns a list of recorded timings.
|
static boolean |
isEnabled()
Checks whether the timing is enabled.
|
static void |
setEnabled(boolean enabled)
Enables/Disables the timing.
|
static void |
submit(String category,
String key,
long durationInNanos)
Submits a new timing for the given key.
|
public static List<Microtiming.Timing> getTimings()
This will only report timings, which changed since the last call of getTimings. Using this approach provides a kind of auto filtering which permits to enable this framework in production systems while still getting reasonable small results.
Microtiming.Timing
values recorded which where submitted since the
last call to getTimings()public static void submit(String category, String key, long durationInNanos)
Adds the average to the "live set" which will be output on the next call to getTimings()
A convenient way to call this method is to use Watch.submitMicroTiming(String, String)
category
- the category of the recorded timing. This permits grouping a microtimings of the same
kind.key
- the key for which the value should be submitteddurationInNanos
- the number of nanoseconds used as timing for the given keypublic static boolean isEnabled()
public static void setEnabled(boolean enabled)
enabled
- determines whether the framework should be enabled or disabledpublic static long getLastReset()
Copyright © 2018. All rights reserved.