mirror of
https://github.com/wpilibsuite/allwpilib
synced 2026-06-21 01:01:43 +00:00
[wpilibc] Output Tracer to DriverStation by default (#2469)
This matches the Java behavior. Also optimizes Java to only create a StringBuffer and call DriverStation.reportWarning if there is data to output.
This commit is contained in:
@@ -83,13 +83,15 @@ public class Tracer {
|
||||
*/
|
||||
public void printEpochs(Consumer<String> output) {
|
||||
long now = RobotController.getFPGATime();
|
||||
StringBuilder sb = new StringBuilder();
|
||||
if (now - m_lastEpochsPrintTime > kMinPrintPeriod) {
|
||||
if (now - m_lastEpochsPrintTime > kMinPrintPeriod) {
|
||||
StringBuilder sb = new StringBuilder();
|
||||
m_lastEpochsPrintTime = now;
|
||||
m_epochs.forEach((key, value) -> {
|
||||
sb.append(String.format("\t%s: %.6fs\n", key, value / 1.0e6));
|
||||
});
|
||||
if (sb.length() > 0) {
|
||||
output.accept(sb.toString());
|
||||
}
|
||||
}
|
||||
output.accept(sb.toString());
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user