Skip to content

Instantly share code, notes, and snippets.

@eruvanos
Created June 14, 2016 13:32
Show Gist options
  • Save eruvanos/f23bf6c622b9b83f188429858507bf9f to your computer and use it in GitHub Desktop.
Save eruvanos/f23bf6c622b9b83f188429858507bf9f to your computer and use it in GitHub Desktop.
StopWatchHolder: Holds Spring Stopwatch as static field and extends a next() method
package de.siemering.gist;
import org.springframework.util.StopWatch;
public class SwHolder{
private static StopWatch sw = new StopWatch();
public static void start(String taskName) throws IllegalStateException {
sw.start(taskName);
}
public static void next(String taskName) throws IllegalStateException {
sw.stop();
sw.start(taskName);
}
public static void stop() throws IllegalStateException {
sw.stop();
}
public static double getTotalTimeSeconds() {
return sw.getTotalTimeSeconds();
}
public static long getTotalTimeMillis() {
return sw.getTotalTimeMillis();
}
public static String shortSummary() {
return sw.shortSummary();
}
public static String prettyPrint() {
return sw.prettyPrint();
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment