Package edu.wpi.first.wpilibj
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 Summary
Constructors Constructor Description Tracer()
Tracer constructor. -
Method Summary
Modifier and Type Method Description void
addEpoch(String epochName)
Adds time since last epoch to the list printed by printEpochs().void
clearEpochs()
Clears all epochs.void
printEpochs()
Prints list of epochs added so far and their times to the DriverStation.void
printEpochs(Consumer<String> output)
Prints list of epochs added so far and their times to the entered String consumer.void
resetTimer()
Restarts the epoch timer.
-
Constructor Details
-
Method Details
-
clearEpochs
Clears all epochs. -
resetTimer
Restarts the epoch timer. -
addEpoch
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
Prints list of epochs added so far and their times to the DriverStation. -
printEpochs
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
-