Class SystemUtils


  • public class SystemUtils
    extends Object
    A utility class for retrieving system data.
    Author:
    oswaldo.bapvic.jr
    • Method Summary

      All Methods Static Methods Concrete Methods 
      Modifier and Type Method Description
      static long getCpuTimeNanos()
      Returns the total time spent using a CPU for the current thread in nanoseconds.
      static long getSystemTimeNanos()
      Returns system time (the time spent running OS kernel code on behalf of your application) in nanoseconds, by calculating the difference between CPU time and user time for the current thread.
      static long getUserTimeNanos()
      Returns the CPU time that the current thread has executed in user mode in nanoseconds (i.e., the time spent running current thread's own code).
      static long getWallClockTimeMillis()
      Returns the current time in milliseconds.
      static long getWallClockTimeNanos()
      Returns the current value of the current Java Virtual Machine's high-resolution time source in nanoseconds.
    • Method Detail

      • getWallClockTimeMillis

        public static long getWallClockTimeMillis()
        Returns the current time in milliseconds.
        Returns:
        the difference, measured in milliseconds, between the current time and midnight, January 1, 1970 UTC.
      • getWallClockTimeNanos

        public static long getWallClockTimeNanos()
        Returns the current value of the current Java Virtual Machine's high-resolution time source in nanoseconds.
        Returns:
        the difference, measured in nanoseconds between current time and some arbitrary origin time for the current JVM, that can be used for measuring elapsed times.
      • getCpuTimeNanos

        public static long getCpuTimeNanos()
        Returns the total time spent using a CPU for the current thread in nanoseconds.
        Returns:
        the total CPU time for the current thread if CPU time measurement is enabled; -1 otherwise.
      • getUserTimeNanos

        public static long getUserTimeNanos()
        Returns the CPU time that the current thread has executed in user mode in nanoseconds (i.e., the time spent running current thread's own code).
        Returns:
        the user-level CPU time for the current thread if CPU time measurement is enabled; -1 otherwise.
      • getSystemTimeNanos

        public static long getSystemTimeNanos()
        Returns system time (the time spent running OS kernel code on behalf of your application) in nanoseconds, by calculating the difference between CPU time and user time for the current thread.
        Returns:
        the system time for the current thread if CPU time measurement is enabled; -1 otherwise.