Performetrics 2.5.3 API

This is the API specification for Performetrics.

Performetrics is a library that provides convenient objects to process the elapsed time spent by the Java Virtual Machine running your application code. It was carefully designed to offer great value in terms of performance and usability, as well as the capability to collect data from multiple time sources with a single method call.

The following counter types are supported:

  • Wall-clock time: the elapsed time experienced by the user waiting for a task to complete (a metric to evaluate the real user experience)
  • CPU time: the total time spent using a CPU for the current thread
  • User time: the total CPU time that the current thread has executed in user mode, i.e., the time spent running current thread's code
  • System time: the time spent by the OS kernel to execute all the basic/system-level operations on behalf of your application, such as context switching, resource allocation, etc.

Examples

1. Using Stopwatch:

Stopwatch stopwatch = Stopwatch.createStarted();
// Do your task
stopwatch.stop();
double d1 = stopwatch.elapsedTime(Counter.Type.WALL_CLOCK_TIME, TimeUnit.NANOSECONDS);
double d2 = stopwatch.elapsedTime(Counter.Type.CPU_TIME, TimeUnit.NANOSECONDS);

2. Using MonitoredRunnable:

MonitoredRunnable operation = Performetrics.monitorOperation(() -> myObject.doStuff());
double d1 = operation.elapsedTime(Counter.Type.USER_TIME, TimeUnit.NANOSECONDS);
double d2 = operation.elapsedTime(Counter.Type.SYSTEM_TIME, TimeUnit.NANOSECONDS);
Packages 
Package Description
net.obvj.performetrics
Provides convenient classes for extracting performance metrics of Java code.
net.obvj.performetrics.config
Provides classes to handle common configuration parameters used by Performetrics.
net.obvj.performetrics.monitors
Provides classes that can monitor other ones.
net.obvj.performetrics.util
Provides utility classes in general.
net.obvj.performetrics.util.print
Provides classes for printing stopwatch data.