org.apache.logging.log4j.util

Class Timer

    • Constructor Detail

      • Timer

        public Timer(String name)
        Constructor.
        Parameters:
        name - the timer name.
      • Timer

        public Timer(String name,
                     int iterations)
        Constructor.
        Parameters:
        name - the timer name.
    • Method Detail

      • start

        public void start()
        Start the timer.
      • startOrResume

        public void startOrResume()
      • stop

        public String stop()
        Stop the timer.
      • pause

        public void pause()
        Pause the timer.
      • resume

        public void resume()
        Resume the timer.
      • getName

        public String getName()
        Accessor for the name.
        Returns:
        the timer's name.
      • getElapsedTime

        public long getElapsedTime()
        Access the elapsed time.
        Returns:
        the elapsed time.
      • getElapsedNanoTime

        public long getElapsedNanoTime()
        Access the elapsed time.
        Returns:
        the elapsed time.
      • getStatus

        public Timer.Status getStatus()
        Returns the name of the last operation performed on this timer (Start, Stop, Pause or Resume).
        Returns:
        the string representing the last operation performed.
      • toString

        public String toString()
        Returns the String representation of the timer based upon its current state
        Overrides:
        toString in class Object
      • formatTo

        public void formatTo(StringBuilder buffer)
        Description copied from interface: StringBuilderFormattable
        Writes a text representation of this object into the specified StringBuilder, ideally without allocating temporary objects.
        Specified by:
        formatTo in interface StringBuilderFormattable
        Parameters:
        buffer - the StringBuilder to write into
      • hashCode

        public int hashCode()
        Overrides:
        hashCode in class Object

Copyright © 1999-2023 The Apache Software Foundation. All Rights Reserved.
Apache Logging, Apache Log4j, Log4j, Apache, the Apache feather logo, the Apache Logging project logo, and the Apache Log4j logo are trademarks of The Apache Software Foundation.