blob: c71dcf5848ab4e122c0b605aed3f2a5d6e8b57f7 [file] [log] [blame]
James Kuszmaul440d8992022-04-29 17:26:59 -07001#include "aos/configuration.h"
Austin Schuh60e77942022-05-16 17:48:24 -07002#include "aos/events/logging/log_reader.h"
3#include "aos/events/timing_report_dump_lib.h"
James Kuszmaul440d8992022-04-29 17:26:59 -07004#include "aos/init.h"
5#include "aos/json_to_flatbuffer.h"
James Kuszmaul440d8992022-04-29 17:26:59 -07006#include "gflags/gflags.h"
7#include "glog/logging.h"
8
9DEFINE_string(application, "",
10 "Application filter to use. Empty for no filter.");
11DEFINE_bool(stream, false, "Stream out all the timing reports in the log.");
12DEFINE_bool(accumulate, true,
13 "Display accumulation of all timing reports at end of log.");
14
15namespace aos {
16struct DumperState {
17 std::unique_ptr<EventLoop> event_loop;
18 std::unique_ptr<TimingReportDump> dumper;
19};
20int 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
55int main(int argc, char *argv[]) {
56 aos::InitGoogle(&argc, &argv);
57 return aos::Main(argc, argv);
58}