aos: Add new --run_for flag to the log_stats tool
I'm adding some functionality to the `log_stats` tool that helps find
inefficiently packed flatbuffers. This method is currently extremely
inefficient. It's sometimes helpful to just look at a portion of the
log. Otherwise, a 10-minute log file can take about 10 minutes to
analyze.
For example, if you only want to run a minute worth of log data, then
specify `--run_for 60` on the command line.
Change-Id: Id433fc1b98eb21c8f52c193d9f34ee4c0f841f1f
Signed-off-by: James Kuszmaul <james.kuszmaul@bluerivertech.com>
diff --git a/aos/events/logging/log_stats.cc b/aos/events/logging/log_stats.cc
index bbed18f..eef0753 100644
--- a/aos/events/logging/log_stats.cc
+++ b/aos/events/logging/log_stats.cc
@@ -21,6 +21,11 @@
"Only print channels that have a set max message size that is more "
"than double of the max message size.");
+DEFINE_double(
+ run_for, 0.0,
+ "If set to a positive value, only process the log for this many seconds. "
+ "Otherwise, process the log until the end of the log.");
+
// This class implements a histogram for tracking message period
// percentiles.
class Histogram {
@@ -355,7 +360,13 @@
LOG(FATAL) << "Could not find any channels";
}
- log_reader_factory.Run();
+ if (FLAGS_run_for > 0.0) {
+ log_reader_factory.RunFor(
+ std::chrono::duration_cast<std::chrono::nanoseconds>(
+ std::chrono::duration<double>(FLAGS_run_for)));
+ } else {
+ log_reader_factory.Run();
+ }
std::cout << std::endl;