Example #1
0
 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;
 }
Example #2
0
 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.";
 }
Example #3
0
 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.";
 }
Example #4
0
 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)";
 }
Example #5
0
 public static long getTimeDeltaMillis(String name) {
   NanoTimerElement timer = users.get(name);
   if (timer == null) return -1;
   timer.refresh();
   return timer.getDiff() / MILLION;
 }
Example #6
0
 public static long getElapsedTimeMillis(String name) {
   NanoTimerElement timer = users.get(name);
   if (timer == null) return -1;
   timer.refresh();
   return timer.getElapsedTime();
 }
Example #7
0
 public static void resetClock(String name) {
   NanoTimerElement timer = users.get(name);
   if (timer == null) return;
   timer.reset();
 }