Austin Schuh | e410614 | 2019-12-01 18:19:53 -0800 | [diff] [blame] | 1 | #include "aos/events/timing_statistics.h" |
| 2 | |
| 3 | #include "aos/events/event_loop_generated.h" |
| 4 | #include "glog/logging.h" |
| 5 | |
| 6 | namespace aos { |
| 7 | namespace internal { |
| 8 | |
| 9 | void RawFetcherTiming::set_timing_report(timing::Fetcher *new_fetcher) { |
Austin Schuh | e410614 | 2019-12-01 18:19:53 -0800 | [diff] [blame] | 10 | fetcher = new_fetcher; |
Brian Silverman | bf88992 | 2021-11-10 12:41:57 -0800 | [diff] [blame^] | 11 | if (!new_fetcher) { |
| 12 | latency.set_statistic(nullptr); |
| 13 | } else { |
| 14 | latency.set_statistic(fetcher->mutable_latency()); |
| 15 | } |
Austin Schuh | e410614 | 2019-12-01 18:19:53 -0800 | [diff] [blame] | 16 | } |
| 17 | |
| 18 | void RawFetcherTiming::ResetTimingReport() { |
Brian Silverman | bf88992 | 2021-11-10 12:41:57 -0800 | [diff] [blame^] | 19 | if (!fetcher) { |
| 20 | return; |
| 21 | } |
| 22 | |
Austin Schuh | e410614 | 2019-12-01 18:19:53 -0800 | [diff] [blame] | 23 | latency.Reset(); |
| 24 | fetcher->mutate_count(0); |
| 25 | } |
| 26 | |
| 27 | void RawSenderTiming::set_timing_report(timing::Sender *new_sender) { |
Austin Schuh | e410614 | 2019-12-01 18:19:53 -0800 | [diff] [blame] | 28 | sender = new_sender; |
Brian Silverman | bf88992 | 2021-11-10 12:41:57 -0800 | [diff] [blame^] | 29 | if (!sender) { |
| 30 | size.set_statistic(nullptr); |
| 31 | } else { |
| 32 | size.set_statistic(sender->mutable_size()); |
| 33 | } |
Austin Schuh | e410614 | 2019-12-01 18:19:53 -0800 | [diff] [blame] | 34 | } |
| 35 | |
| 36 | void RawSenderTiming::ResetTimingReport() { |
Brian Silverman | bf88992 | 2021-11-10 12:41:57 -0800 | [diff] [blame^] | 37 | if (!sender) { |
| 38 | return; |
| 39 | } |
| 40 | |
Austin Schuh | e410614 | 2019-12-01 18:19:53 -0800 | [diff] [blame] | 41 | size.Reset(); |
| 42 | sender->mutate_count(0); |
| 43 | } |
| 44 | |
| 45 | void TimerTiming::set_timing_report(timing::Timer *new_timer) { |
Austin Schuh | e410614 | 2019-12-01 18:19:53 -0800 | [diff] [blame] | 46 | timer = new_timer; |
Brian Silverman | bf88992 | 2021-11-10 12:41:57 -0800 | [diff] [blame^] | 47 | if (!timer) { |
| 48 | wakeup_latency.set_statistic(nullptr); |
| 49 | handler_time.set_statistic(nullptr); |
| 50 | } else { |
| 51 | wakeup_latency.set_statistic(timer->mutable_wakeup_latency()); |
| 52 | handler_time.set_statistic(timer->mutable_handler_time()); |
| 53 | } |
Austin Schuh | e410614 | 2019-12-01 18:19:53 -0800 | [diff] [blame] | 54 | } |
| 55 | |
| 56 | void TimerTiming::ResetTimingReport() { |
Brian Silverman | bf88992 | 2021-11-10 12:41:57 -0800 | [diff] [blame^] | 57 | if (!timer) { |
| 58 | return; |
| 59 | } |
| 60 | |
Austin Schuh | e410614 | 2019-12-01 18:19:53 -0800 | [diff] [blame] | 61 | wakeup_latency.Reset(); |
| 62 | handler_time.Reset(); |
| 63 | timer->mutate_count(0); |
| 64 | } |
| 65 | |
| 66 | } // namespace internal |
| 67 | } // namespace aos |