Package arc.util

Class PerformanceCounter

java.lang.Object
arc.util.PerformanceCounter

public class PerformanceCounter extends Object
Class to keep track of the time and load (percentage of total time) a specific task takes. Call start() just before starting the task and stop() right after. You can do this multiple times if required. Every render or update call tick() to update the values. The time FloatCounter provides access to the minimum, maximum, average, total and current time (in seconds) the task takes. Likewise for the load value, which is the percentage of the total time.
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    float
    The current value in seconds, you can manually increase this using your own timing mechanism if needed, if you do so, you also need to update valid.
    The load value of this counter
    final String
    The name of this counter
    The time value of this counter (seconds)
    boolean
    Flag to indicate that the current value is valid, you need to set this to true if using your own timing mechanism
  • Constructor Summary

    Constructors
    Constructor
    Description
     
    PerformanceCounter(String name, int windowSize)
     
  • Method Summary

    Modifier and Type
    Method
    Description
    void
    Resets this performance counter to its defaults values.
    void
    Start counting, call this method just before performing the task you want to keep track of.
    void
    Stop counting, call this method right after you performed the task you want to keep track of.
    void
    Updates the time and load counters and resets the time.
    void
    tick(float delta)
    Updates the time and load counters and resets the time.
    Creates a string in the form of "name [time: value, load: value]"

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
  • Field Details

    • time

      public final FloatCounter time
      The time value of this counter (seconds)
    • load

      public final FloatCounter load
      The load value of this counter
    • name

      public final String name
      The name of this counter
    • current

      public float current
      The current value in seconds, you can manually increase this using your own timing mechanism if needed, if you do so, you also need to update valid.
    • valid

      public boolean valid
      Flag to indicate that the current value is valid, you need to set this to true if using your own timing mechanism
  • Constructor Details

    • PerformanceCounter

      public PerformanceCounter(String name)
    • PerformanceCounter

      public PerformanceCounter(String name, int windowSize)
  • Method Details

    • tick

      public void tick()
      Updates the time and load counters and resets the time. Call start() to begin a new count. The values are only valid after at least two calls to this method.
    • tick

      public void tick(float delta)
      Updates the time and load counters and resets the time. Call start() to begin a new count.
      Parameters:
      delta - The time since the last call to this method
    • start

      public void start()
      Start counting, call this method just before performing the task you want to keep track of. Call stop() when done.
    • stop

      public void stop()
      Stop counting, call this method right after you performed the task you want to keep track of. Call start() again when you perform more of that task.
    • reset

      public void reset()
      Resets this performance counter to its defaults values.
    • toString

      public String toString()
      Overrides:
      toString in class Object
    • toString

      public StringBuilder toString(StringBuilder sb)
      Creates a string in the form of "name [time: value, load: value]"