Class ElapsedTimer

java.lang.Object
com.ibm.icu.dev.util.ElapsedTimer

public final class ElapsedTimer extends Object
Simple stopwatch timer. Usage: { ElapsedTimer et = new ElapsedTimer(); do_some_stuff; System.out.println("It took " + et + " to do stuff."); } Advanced: { ElapsedTimer et = new ElapsedTimer("Thing2's time: {0}"); // messageformat pattern do_thing_2(); System.out.println(et.toString()); } More advanced: NumberFormat and/or MessageFormat can be provided in the constructor
  • Field Details

    • startTime

      private long startTime
    • myDurationFormat

      private NumberFormat myDurationFormat
    • myMsgFormat

      private MessageFormat myMsgFormat
    • gFormat

      private static NumberFormat gFormat
  • Constructor Details

  • Method Details

    • elapsedTime

      public static String elapsedTime(long start, long end)
      Convenience method to print the elasped time (in milliseconds)
    • elapsedTime

      public static String elapsedTime(long start)
    • toString

      public final String toString()
      Overrides:
      toString in class Object
      Returns:
      elapsed time in seconds since object creation
    • getFormat

      private static NumberFormat getFormat()
    • diffTime

      private static String diffTime(NumberFormat fmt, long start, long end)