Class ElapsedTime


  • public class ElapsedTime
    extends Object
    Utility class to measure execution time of a block of code (closure-based)
    Author:
    royer
    • Field Detail

      • sStandardOutput

        public static boolean sStandardOutput
        This flag can be set statically to enable/disable stdout logging of elapsed times. Practical for performance evaluation.
    • Constructor Detail

      • ElapsedTime

        public ElapsedTime()
    • Method Detail

      • measure

        public static double measure​(String pDescription,
                                     Runnable pRunnable)
        Measures the elapsed time of a Runnable.
        Parameters:
        pDescription - description of the runnable
        pRunnable - runnable
        Returns:
        elapsed time in milliseconds
      • measureForceOutput

        public static double measureForceOutput​(String pDescription,
                                                Runnable pRunnable)
        Measures the elapsed time of a Runnable. This version forces the outputto standard out.
        Parameters:
        pDescription - description of the runnable
        pRunnable - runnable
        Returns:
        elapsed time in milliseconds
      • measure

        public static double measure​(boolean pActive,
                                     String pDescription,
                                     Runnable pRunnable)
        Measures the elapsed time of a Runnable. An optional boolean flag can be used to switch of the timing.
        Parameters:
        pActive - true measure, false execute without measuring
        pDescription - description of the code (runnable)
        pRunnable - runnable
        Returns:
        elapsed time in milliseconds
      • measure

        public static double measure​(boolean pActive,
                                     boolean pForceOutput,
                                     String pDescription,
                                     Runnable pRunnable)
        Measures the elapsed time of a Runnable. An optional boolean flag can be used to switch of the timing.
        Parameters:
        pActive - true measure, false execute without measuring
        pForceOutput - forces output to standard out
        pDescription - description of the code (runnable)
        pRunnable - runnable
        Returns:
        elapsed time in milliseconds