Class StopWatch

java.lang.Object
org.springframework.util.StopWatch

public class StopWatch extends Object
Simple stop watch, allowing for timing of a number of tasks, exposing total running time and running time for each named task.

Conceals use of System.nanoTime(), improving the readability of application code and reducing the likelihood of calculation errors.

Note that this object is not designed to be thread-safe and does not use synchronization.

This class is normally used to verify performance during proof-of-concept work and in development, rather than as part of production applications.

As of Spring Framework 5.2, running time is tracked and reported in nanoseconds. As of 6.1, the default time unit for String renderings is seconds with decimal points in nanosecond precision. Custom renderings with specific time units can be requested through prettyPrint(TimeUnit).

Since:
May 2, 2001
Author:
Rod Johnson, Juergen Hoeller, Sam Brannen
See Also: