public static long getItemCountPerSecond(String name, long elements) { NanoTimerElement timer = users.get(name); timer.refresh(); if (timer == null) return -1; if (elements < 0) return -1; if (timer.getElapsedTime() == 0) return -1; long items = (BILLION * elements) / timer.getElapsedTime(); return items; }
public static String getElapsedTimeStringAsMillis(String name) { NanoTimerElement timer = users.get(name); if (timer == null) return "Invalid chronometer: " + name; ; timer.refresh(); return "Delta: " + timer.getDiff() / MILLION + "ms. Elapsed: " + timer.getElapsedTime() / MILLION + " ms."; }
public static String getElapsedTimeString(String name) { NanoTimerElement timer = users.get(name); if (timer == null) return "Invalid chronometer: " + name; ; timer.refresh(); return "Delta: " + formatter.format((double) timer.getDiff() / BILLION) + " s. Elapsed: " + formatter.format((double) timer.getElapsedTime() / BILLION) + " s."; }
public static String stopClock(String name) { NanoTimerElement timer = users.get(name); if (timer == null) return name + " : Invalid chronometer"; timer.refresh(); users.remove(name); return "" + (double) timer.elapsedTime / BILLION + "s." + "(" + timer.elapsedTime / MILLION + " ms)"; }
public static long getTimeDeltaMillis(String name) { NanoTimerElement timer = users.get(name); if (timer == null) return -1; timer.refresh(); return timer.getDiff() / MILLION; }
public static long getElapsedTimeMillis(String name) { NanoTimerElement timer = users.get(name); if (timer == null) return -1; timer.refresh(); return timer.getElapsedTime(); }
public static void resetClock(String name) { NanoTimerElement timer = users.get(name); if (timer == null) return; timer.reset(); }