| OLD | NEW |
| 1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #ifndef REMOTING_PROTOCOL_PERFORMANCE_TRACKER_H_ | 5 #ifndef REMOTING_PROTOCOL_PERFORMANCE_TRACKER_H_ |
| 6 #define REMOTING_PROTOCOL_PERFORMANCE_TRACKER_H_ | 6 #define REMOTING_PROTOCOL_PERFORMANCE_TRACKER_H_ |
| 7 | 7 |
| 8 #include <stdint.h> | 8 #include <stdint.h> |
| 9 | 9 |
| 10 #include <map> | 10 #include <map> |
| 11 | 11 |
| 12 #include "base/callback.h" | 12 #include "base/callback.h" |
| 13 #include "base/macros.h" | 13 #include "base/macros.h" |
| 14 #include "base/timer/timer.h" | 14 #include "base/timer/timer.h" |
| 15 #include "remoting/base/rate_counter.h" | 15 #include "remoting/base/rate_counter.h" |
| 16 #include "remoting/base/running_average.h" | 16 #include "remoting/base/running_samples.h" |
| 17 | 17 |
| 18 namespace remoting { | 18 namespace remoting { |
| 19 | 19 |
| 20 class VideoPacket; | 20 class VideoPacket; |
| 21 | 21 |
| 22 namespace protocol { | 22 namespace protocol { |
| 23 | 23 |
| 24 // PerformanceTracker defines a bundle of performance counters and statistics | 24 // PerformanceTracker defines a bundle of performance counters and statistics |
| 25 // for chromoting. | 25 // for chromoting. |
| 26 class PerformanceTracker { | 26 class PerformanceTracker { |
| (...skipping 15 matching lines...) Expand all Loading... |
| 42 virtual ~PerformanceTracker(); | 42 virtual ~PerformanceTracker(); |
| 43 | 43 |
| 44 // Constant used to calculate the average for rate metrics and used by the | 44 // Constant used to calculate the average for rate metrics and used by the |
| 45 // plugin for the frequency at which stats should be updated. | 45 // plugin for the frequency at which stats should be updated. |
| 46 static const int kStatsUpdatePeriodSeconds = 1; | 46 static const int kStatsUpdatePeriodSeconds = 1; |
| 47 | 47 |
| 48 // Return rates and running-averages for different metrics. | 48 // Return rates and running-averages for different metrics. |
| 49 double video_bandwidth() { return video_bandwidth_.Rate(); } | 49 double video_bandwidth() { return video_bandwidth_.Rate(); } |
| 50 double video_frame_rate() { return video_frame_rate_.Rate(); } | 50 double video_frame_rate() { return video_frame_rate_.Rate(); } |
| 51 double video_packet_rate() { return video_packet_rate_.Rate(); } | 51 double video_packet_rate() { return video_packet_rate_.Rate(); } |
| 52 double video_capture_ms() { return video_capture_ms_.Average(); } | 52 const RunningSamples& video_capture_ms() { return video_capture_ms_; } |
| 53 double video_encode_ms() { return video_encode_ms_.Average(); } | 53 const RunningSamples& video_encode_ms() { return video_encode_ms_; } |
| 54 double video_decode_ms() { return video_decode_ms_.Average(); } | 54 const RunningSamples& video_decode_ms() { return video_decode_ms_; } |
| 55 double video_paint_ms() { return video_paint_ms_.Average(); } | 55 const RunningSamples& video_paint_ms() { return video_paint_ms_; } |
| 56 double round_trip_ms() { return round_trip_ms_.Average(); } | 56 const RunningSamples& round_trip_ms() { return round_trip_ms_; } |
| 57 | 57 |
| 58 // Record stats for a video-packet. | 58 // Record stats for a video-packet. |
| 59 void RecordVideoPacketStats(const VideoPacket& packet); | 59 void RecordVideoPacketStats(const VideoPacket& packet); |
| 60 | 60 |
| 61 // Helpers to track decode and paint time. If the render drops some frames | 61 // Helpers to track decode and paint time. If the render drops some frames |
| 62 // before they are painted then OnFramePainted() records paint time when the | 62 // before they are painted then OnFramePainted() records paint time when the |
| 63 // following frame is rendered. OnFramePainted() may be called multiple times, | 63 // following frame is rendered. OnFramePainted() may be called multiple times, |
| 64 // in which case all calls after the first one are ignored. | 64 // in which case all calls after the first one are ignored. |
| 65 void OnFrameDecoded(int32_t frame_id); | 65 void OnFrameDecoded(int32_t frame_id); |
| 66 void OnFramePainted(int32_t frame_id); | 66 void OnFramePainted(int32_t frame_id); |
| (...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 106 | 106 |
| 107 // Video packets per second, including empty video-packets. | 107 // Video packets per second, including empty video-packets. |
| 108 // This will be greater than the frame rate, as individual frames are | 108 // This will be greater than the frame rate, as individual frames are |
| 109 // contained in packets, some of which might be empty (e.g. when there are no | 109 // contained in packets, some of which might be empty (e.g. when there are no |
| 110 // screen changes). | 110 // screen changes). |
| 111 RateCounter video_packet_rate_; | 111 RateCounter video_packet_rate_; |
| 112 | 112 |
| 113 // The following running-averages are uploaded to UMA per video packet and | 113 // The following running-averages are uploaded to UMA per video packet and |
| 114 // also used for display to users, averaged over the N most recent samples. | 114 // also used for display to users, averaged over the N most recent samples. |
| 115 // N = kLatencySampleSize. | 115 // N = kLatencySampleSize. |
| 116 RunningAverage video_capture_ms_; | 116 RunningSamples video_capture_ms_; |
| 117 RunningAverage video_encode_ms_; | 117 RunningSamples video_encode_ms_; |
| 118 RunningAverage video_decode_ms_; | 118 RunningSamples video_decode_ms_; |
| 119 RunningAverage video_paint_ms_; | 119 RunningSamples video_paint_ms_; |
| 120 RunningAverage round_trip_ms_; | 120 RunningSamples round_trip_ms_; |
| 121 | 121 |
| 122 // Used to update UMA stats, if set. | 122 // Used to update UMA stats, if set. |
| 123 UpdateUmaCustomHistogramCallback uma_custom_counts_updater_; | 123 UpdateUmaCustomHistogramCallback uma_custom_counts_updater_; |
| 124 UpdateUmaCustomHistogramCallback uma_custom_times_updater_; | 124 UpdateUmaCustomHistogramCallback uma_custom_times_updater_; |
| 125 UpdateUmaEnumHistogramCallback uma_enum_histogram_updater_; | 125 UpdateUmaEnumHistogramCallback uma_enum_histogram_updater_; |
| 126 | 126 |
| 127 // The latest event timestamp that a VideoPacket was seen annotated with. | 127 // The latest event timestamp that a VideoPacket was seen annotated with. |
| 128 base::TimeTicks latest_event_timestamp_; | 128 base::TimeTicks latest_event_timestamp_; |
| 129 | 129 |
| 130 // Stores timestamps for the frames that are currently being processed. | 130 // Stores timestamps for the frames that are currently being processed. |
| 131 FramesTimestampsMap frame_timestamps_; | 131 FramesTimestampsMap frame_timestamps_; |
| 132 | 132 |
| 133 bool is_paused_ = false; | 133 bool is_paused_ = false; |
| 134 | 134 |
| 135 base::RepeatingTimer upload_uma_stats_timer_; | 135 base::RepeatingTimer upload_uma_stats_timer_; |
| 136 | 136 |
| 137 DISALLOW_COPY_AND_ASSIGN(PerformanceTracker); | 137 DISALLOW_COPY_AND_ASSIGN(PerformanceTracker); |
| 138 }; | 138 }; |
| 139 | 139 |
| 140 } // namespace protocol | 140 } // namespace protocol |
| 141 } // namespace remoting | 141 } // namespace remoting |
| 142 | 142 |
| 143 #endif // REMOTING_PROTOCOL_PERFORMANCE_TRACKER_H_ | 143 #endif // REMOTING_PROTOCOL_PERFORMANCE_TRACKER_H_ |
| OLD | NEW |