Class Profiler
Data is published to /Profiling, with CPU time utilized by the garbage
collector published at /Profiling/gc, and time spent publishing values to
NT at /Profiling/overhead. All timings are recorded in milliseconds,
as the duration of execution. The profiler records the time to execute blocks
of code, with support for nesting execution times which are reflected in an
expanding NT tree.
All invocations of start(String) are expected to be
followed by a closing end(). Additionally, it is expected
that a single start(String)/end() pair is
found at the highest level of the robot's code, with no other "root" pairs
(this is already done if utilizing LoggedRobot). If either of these
limitations are left unsatisfied, an error will be printed to the Driver Station
console. Profiling across threads is also not supported.
-
Method Summary
Modifier and TypeMethodDescriptionstatic voidend()Ends profiling a section of code.static booleanDetermines if the profiler is currently running.static voidProfiles a section of user code.static <T> TProfiles a section of user code.static voidStarts to profile a section of user code.
-
Method Details
-
isRunning
public static boolean isRunning()Determines if the profiler is currently running.- Returns:
trueif the profiler is running.
-
run
Profiles a section of user code. Serves as a shorthand for callingstart(String), {user code},end().- Parameters:
name- The name of the call. Must be unique.runnable- The user code to be ran.
-
run
Profiles a section of user code. Serves as a shorthand for callingstart(String), {user code},end().- Type Parameters:
T- The return type of the supplier.- Parameters:
name- The name of the call. Must be unique.- Returns:
- The value returned from the supplier.
-
start
Starts to profile a section of user code. This method should be invoked before the user code to be profiled, withend()expected to be after. Additionalstart(String)/end()pairs can be nested within the section of user code, and will appear as a sub-topic in NetworkTables. Timings of nested pairs are still included in the overall time recorded by the parent pair.- Parameters:
name- The name of the call. Must be unique.
-
end
public static void end()Ends profiling a section of code. This method should be invoked after the user code to be profiled. Trailing calls to this method will result in an error printed to the Driver Station console.
-