Class Tracer

java.lang.Object
edu.wpi.first.wpilibj.Tracer

public class Tracer
extends Object
A class for keeping track of how much time it takes for different parts of code to execute. This is done with epochs, that are added by calls to addEpoch(String), and can be printed with a call to printEpochs().

Epochs are a way to partition the time elapsed so that when overruns occur, one can determine which parts of an operation consumed the most time.

  • Constructor Details

  • Method Details

    • clearEpochs

      public void clearEpochs()
      Clears all epochs.
    • resetTimer

      public void resetTimer()
      Restarts the epoch timer.
    • addEpoch

      public void addEpoch​(String epochName)
      Adds time since last epoch to the list printed by printEpochs().

      Epochs are a way to partition the time elapsed so that when overruns occur, one can determine which parts of an operation consumed the most time.

      This should be called immediately after execution has finished, with a call to this method or resetTimer() before execution.

      Parameters:
      epochName - The name to associate with the epoch.
    • printEpochs

      public void printEpochs()
      Prints list of epochs added so far and their times to the DriverStation.
    • printEpochs

      public void printEpochs​(Consumer<String> output)
      Prints list of epochs added so far and their times to the entered String consumer.

      This overload can be useful for logging to a file, etc.

      Parameters:
      output - the stream that the output is sent to