[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:
Peter Johnson
2020-04-05 23:09:21 -07:00
committed by GitHub
parent cb51029335
commit b46b5df16a
3 changed files with 32 additions and 10 deletions

View File

@@ -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());
}
}