Class ProcessingProfiler


  • public final class ProcessingProfiler
    extends java.lang.Object
    Small utility class to measure ns-level processing delays
    Author:
    rstein
    • Field Summary

      Fields 
      Modifier and Type Field Description
      protected static boolean debugState
      boolean flag controlling whether diagnostics time-marks are taken or the routine to be skipped
      protected static boolean loggerOutput
      boolean flag controlling whether the statistics/time differences are output to the logger/console or not
      protected static boolean verboseOutput
      boolean flag controlling whether the statistics/time differences are output to the logger/console or not
    • Method Summary

      All Methods Static Methods Concrete Methods 
      Modifier and Type Method Description
      static java.util.List<java.lang.String> getCallingClassMethod​(int... recursionDepth)  
      protected static java.lang.String getCallingClassMethod​(java.lang.String msg)  
      static boolean getDebugState()  
      static boolean getLoggerOutputState()  
      static long getTimeDiff​(long lastStamp)  
      static long getTimeDiff​(long lastStamp, java.lang.String msg)  
      static long getTimeStamp()
      Returns the current value of the running Java Virtual Machine's high-resolution time source, in nanoseconds.
      static boolean getVerboseOutputState()  
      static void setDebugState​(boolean state)
      boolean flag controlling whether diagnostics time-marks are taken or the routine to be skipped
      static void setLoggerOutputState​(boolean state)
      boolean flag controlling whether the statistics/time differences are output to the logger/console or not
      static void setVerboseOutputState​(boolean state)
      boolean flag controlling whether the statistics/time differences are output to the logger/console or not
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Field Detail

      • debugState

        protected static boolean debugState
        boolean flag controlling whether diagnostics time-marks are taken or the routine to be skipped
      • verboseOutput

        protected static boolean verboseOutput
        boolean flag controlling whether the statistics/time differences are output to the logger/console or not
      • loggerOutput

        protected static boolean loggerOutput
        boolean flag controlling whether the statistics/time differences are output to the logger/console or not
    • Method Detail

      • setDebugState

        public static void setDebugState​(boolean state)
        boolean flag controlling whether diagnostics time-marks are taken or the routine to be skipped
        Parameters:
        state - true: enable
      • getDebugState

        public static boolean getDebugState()
        Returns:
        boolean flag controlling whether diagnostics time-marks are taken or the routine to be skipped
      • setVerboseOutputState

        public static void setVerboseOutputState​(boolean state)
        boolean flag controlling whether the statistics/time differences are output to the logger/console or not
        Parameters:
        state - true: enable
      • getVerboseOutputState

        public static boolean getVerboseOutputState()
        Returns:
        boolean flag controlling whether the statistics/time differences are output to the logger/console or not
      • setLoggerOutputState

        public static void setLoggerOutputState​(boolean state)
        boolean flag controlling whether the statistics/time differences are output to the logger/console or not
        Parameters:
        state - true: enable
      • getLoggerOutputState

        public static boolean getLoggerOutputState()
        Returns:
        boolean flag controlling whether the statistics/time differences are output to the logger/console or not
      • getTimeStamp

        public static long getTimeStamp()
        Returns the current value of the running Java Virtual Machine's high-resolution time source, in nanoseconds.

        This method can only be used to measure elapsed time and is not related to any other notion of system or wall-clock time. The value returned represents nanoseconds since some fixed but arbitrary origin time.

        the overhead of taking the time stamp is disabled via #debugProperty()

        Returns:
        nanoSecond resolution time stam
      • getTimeDiff

        public static long getTimeDiff​(long lastStamp)
        Parameters:
        lastStamp - reference time stamp
        Returns:
        actual delay
      • getCallingClassMethod

        public static java.util.List<java.lang.String> getCallingClassMethod​(int... recursionDepth)
        Parameters:
        recursionDepth - 0 being the calling function
        Returns:
        the 'class::function(line:xxx)' string
      • getCallingClassMethod

        protected static java.lang.String getCallingClassMethod​(java.lang.String msg)
      • getTimeDiff

        public static long getTimeDiff​(long lastStamp,
                                       java.lang.String msg)
        Parameters:
        lastStamp - reference time stamp
        msg - custom string message that should be printed alongside the time stamp
        Returns:
        actual delay