James Kuszmaul | 440d899 | 2022-04-29 17:26:59 -0700 | [diff] [blame] | 1 | #include "aos/configuration.h" |
Austin Schuh | 60e7794 | 2022-05-16 17:48:24 -0700 | [diff] [blame^] | 2 | #include "aos/events/logging/log_reader.h" |
| 3 | #include "aos/events/timing_report_dump_lib.h" |
James Kuszmaul | 440d899 | 2022-04-29 17:26:59 -0700 | [diff] [blame] | 4 | #include "aos/init.h" |
| 5 | #include "aos/json_to_flatbuffer.h" |
James Kuszmaul | 440d899 | 2022-04-29 17:26:59 -0700 | [diff] [blame] | 6 | #include "gflags/gflags.h" |
| 7 | #include "glog/logging.h" |
| 8 | |
| 9 | DEFINE_string(application, "", |
| 10 | "Application filter to use. Empty for no filter."); |
| 11 | DEFINE_bool(stream, false, "Stream out all the timing reports in the log."); |
| 12 | DEFINE_bool(accumulate, true, |
| 13 | "Display accumulation of all timing reports at end of log."); |
| 14 | |
| 15 | namespace aos { |
| 16 | struct DumperState { |
| 17 | std::unique_ptr<EventLoop> event_loop; |
| 18 | std::unique_ptr<TimingReportDump> dumper; |
| 19 | }; |
| 20 | int Main(int argc, char *argv[]) { |
| 21 | if (argc < 2) { |
| 22 | LOG(ERROR) << "Expected at least 1 logfile as an argument"; |
| 23 | return 1; |
| 24 | } |
| 25 | aos::logger::LogReader reader( |
| 26 | aos::logger::SortParts(aos::logger::FindLogs(argc, argv))); |
| 27 | reader.Register(); |
| 28 | { |
| 29 | std::vector<DumperState> dumpers; |
| 30 | for (const aos::Node *node : aos::configuration::GetNodes( |
| 31 | reader.event_loop_factory()->configuration())) { |
| 32 | std::unique_ptr<aos::EventLoop> event_loop = |
| 33 | reader.event_loop_factory()->MakeEventLoop("timing_reports", node); |
| 34 | event_loop->SkipTimingReport(); |
| 35 | event_loop->SkipAosLog(); |
| 36 | std::unique_ptr<TimingReportDump> dumper = |
| 37 | std::make_unique<TimingReportDump>( |
| 38 | event_loop.get(), |
| 39 | FLAGS_accumulate ? TimingReportDump::AccumulateStatistics::kYes |
| 40 | : TimingReportDump::AccumulateStatistics::kNo, |
| 41 | FLAGS_stream ? TimingReportDump::StreamResults::kYes |
| 42 | : TimingReportDump::StreamResults::kNo); |
| 43 | if (!FLAGS_application.empty()) { |
| 44 | dumper->ApplicationFilter(FLAGS_application); |
| 45 | } |
| 46 | dumpers.push_back({std::move(event_loop), std::move(dumper)}); |
| 47 | } |
| 48 | reader.event_loop_factory()->Run(); |
| 49 | } |
| 50 | reader.Deregister(); |
| 51 | return EXIT_SUCCESS; |
| 52 | } |
| 53 | } // namespace aos |
| 54 | |
| 55 | int main(int argc, char *argv[]) { |
| 56 | aos::InitGoogle(&argc, &argv); |
| 57 | return aos::Main(argc, argv); |
| 58 | } |