Class Timer

java.lang.Object
com.decs.application.services.Timer

@Service public class Timer extends Object
Timer Class

This class handles time measurements in the system's execution environment (Java Virtual Machine)

Version:
1.0
Author:
Bruno Guiomar
  • Field Details

  • Constructor Details

    • Timer

      public Timer()
      Class Constructor
  • Method Details

    • computeTime

      public static long computeTime(long initial, long finish)
      Computes the elapsed wall-clock time between two instants
      Parameters:
      initial - Initial instant
      finish - Final instant
      Returns:
      Elapsed wall-clock time between the final and initial instants
    • getWallClockTimestamp

      public static long getWallClockTimestamp()
      Returns:
      Wall-clock timestamp in nanoseconds
    • getCPUTimestamp

      public static long getCPUTimestamp(ThreadMXBean threadMXBean)
      Parameters:
      threadMXBean - Management interface object for the thread system of the JVM
      Returns:
      CPU timestamp in nanoseconds
    • nano2milis

      public static long nano2milis(long value)
      Converts a value expressed in nanoseconds to milliseconds
      Parameters:
      value - Value in nanoseconds
      Returns:
      Value in milliseconds
    • nano2seconds

      public static long nano2seconds(long value)
      Converts a value expressed in nanoseconds to seconds
      Parameters:
      value - Value in nanoseconds
      Returns:
      Value in seconds