Package nzilbb.util

Class Timers


  • public class Timers
    extends Object
    Maintains a set of named timers, primarily for performance tests.
    Author:
    Robert Fromont robert@fromont.net.nz
    • Constructor Detail

      • Timers

        public Timers()
        Default constructor.
    • Method Detail

      • getRunningTimers

        public LinkedHashMap<String,​Long> getRunningTimers()
        Getter for runningTimers: Currently running timers - a map of IDs to start times.
        Returns:
        Currently running timers - a map of IDs to start times.
      • setRunningTimers

        public Timers setRunningTimers​(LinkedHashMap<String,​Long> newRunningTimers)
        Setter for runningTimers: Currently running timers - a map of IDs to start times.
        Parameters:
        newRunningTimers - Currently running timers - a map of IDs to start times.
      • getTotals

        public LinkedHashMap<String,​Long> getTotals()
        Getter for totals: Timer totals - a map of IDs to total run times.
        Returns:
        Timer totals - a map of IDs to total run times.
      • setTotals

        public Timers setTotals​(LinkedHashMap<String,​Long> newTotals)
        Setter for totals: Timer totals - a map of IDs to total run times.
        Parameters:
        newTotals - Timer totals - a map of IDs to total run times.
      • start

        public long start​(String id)
        Start a timer.
        Parameters:
        id - The ID of the timer.
        Returns:
        The current time.
      • end

        public long end​(String id)
        Ends a timer and adds the duration to the total for the given ID.
        Parameters:
        id - The ID of the timer.
        Returns:
        Duration for this timer in ms.
      • durationMilliseconds

        public long durationMilliseconds​(String id)
        Get the duration of the given timer in milliseconds.
        Parameters:
        id -
        Returns:
        The duration of the given timer in milliseconds, or 0 if the timer is unknown.
      • durationSeconds

        public double durationSeconds​(String id)
        Get the duration of the given timer in seconds.
        Parameters:
        id -
        Returns:
        The duration of the given timer in seconds, or 0.0 if the timer is unknown.
      • toString

        public String toString()
        String representation of the totals.
        Overrides:
        toString in class Object
        Returns:
        String representation of the totals.