Index: remoting/client/plugin/chromoting_instance.cc |
diff --git a/remoting/client/plugin/chromoting_instance.cc b/remoting/client/plugin/chromoting_instance.cc |
index c32d31ded27bcd4d333f047d9af82c1536d5442a..df8c7ee745ee9f65f658d57a469feedcd825a4cf 100644 |
--- a/remoting/client/plugin/chromoting_instance.cc |
+++ b/remoting/client/plugin/chromoting_instance.cc |
@@ -32,6 +32,7 @@ |
#include "ppapi/cpp/dev/url_util_dev.h" |
#include "ppapi/cpp/image_data.h" |
#include "ppapi/cpp/input_event.h" |
+#include "ppapi/cpp/private/uma_private.h" |
#include "ppapi/cpp/rect.h" |
#include "ppapi/cpp/var_array_buffer.h" |
#include "ppapi/cpp/var_dictionary.h" |
@@ -73,6 +74,26 @@ const int kPerfStatsIntervalMs = 1000; |
// URL scheme used by Chrome apps and extensions. |
const char kChromeExtensionUrlScheme[] = "chrome-extension"; |
+// The boundary value for the FPS histogram: we don't expect video frame-rate to |
+// be greater than 40fps. |
+// Histograms expect samples to be less than the boundary value, so set to 41. |
+const int kMaxFrameRate = 41; |
+// For bandwidth, we'll use a histogram ranging from 0 to 1MB/s, spread across |
+// 1000 buckets. |
+// Histograms are log-scaled by default. This results in fine-grained buckets at |
+// lower values and wider-ranged buckets closer to the maximum. |
+// Values above the maximum defined here end up in the right-most bucket. |
+// See $/src/base/metrics/histogram.h for more details. |
+const int kBandwidthHistogramMin = 1; |
+const int kBandwidthHistogramMax = 1024000; |
+const int kBandwidthHistogramNumBuckets = 1000; |
+ |
+// For the latency metrics, we'll set the max histogram value to 20,000ms, split |
+// over 1000 buckets. |
+const int kLatencyHistogramMin = 1; |
+const int kLatencyHistogramMax = 20000; |
+const int kLatencyHistogramNumBuckets = 1000; |
+ |
#if defined(USE_OPENSSL) |
// Size of the random seed blob used to initialize RNG in libjingle. Libjingle |
// uses the seed only for OpenSSL builds. OpenSSL needs at least 32 bytes of |
@@ -1054,16 +1075,42 @@ void ChromotingInstance::SendPerfStats() { |
weak_factory_.GetWeakPtr()), |
base::TimeDelta::FromMilliseconds(kPerfStatsIntervalMs)); |
+ // Update performance stats, averaged over the past few seconds. |
+ // These are eventually upstreamed to the web-app, and also available for |
+ // display to the user. |
scoped_ptr<base::DictionaryValue> data(new base::DictionaryValue()); |
ChromotingStats* stats = video_renderer_->GetStats(); |
- data->SetDouble("videoBandwidth", stats->video_bandwidth()->Rate()); |
- data->SetDouble("videoFrameRate", stats->video_frame_rate()->Rate()); |
+ data->SetDouble("videoBandwidth", |
+ stats->video_Bps_webapp()->Rate()); |
+ data->SetDouble("videoFrameRate", stats->video_fps_webapp()->Rate()); |
data->SetDouble("captureLatency", stats->video_capture_ms()->Average()); |
data->SetDouble("encodeLatency", stats->video_encode_ms()->Average()); |
data->SetDouble("decodeLatency", stats->video_decode_ms()->Average()); |
data->SetDouble("renderLatency", stats->video_paint_ms()->Average()); |
data->SetDouble("roundtripLatency", stats->round_trip_ms()->Average()); |
PostLegacyJsonMessage("onPerfStats", data.Pass()); |
+ |
+ // Update UMA histograms for video frame-rate, bandwidth and latencies. |
+ // These metrics will be averaged over the last second. |
+ pp::UMAPrivate uma_interface(this); |
+ uma_interface.HistogramEnumeration( |
+ "Chromoting.Video.FrameRate", stats->video_Bps_UMA()->Rate(), |
+ kMaxFrameRate); |
+ uma_interface.HistogramEnumeration( |
+ "Chromoting.Video.FrameRate", |
+ stats->video_packets_per_s_UMA()->Rate(), kMaxFrameRate); |
+ uma_interface.HistogramCustomCounts("Chromoting.Video.Bandwidth", |
+ stats->video_Bps_UMA()->Rate(), kBandwidthHistogramMin, |
+ kBandwidthHistogramMax, kBandwidthHistogramNumBuckets); |
+ uma_interface.HistogramCustomTimes("Chromoting.Video.CaptureLatency", |
+ stats->video_capture_ms()->Average(), kLatencyHistogramMin, |
+ kLatencyHistogramMax, kLatencyHistogramNumBuckets); |
+ uma_interface.HistogramCustomTimes("Chromoting.Video.EncodeLatency", |
+ stats->video_encode_ms()->Average(), kLatencyHistogramMin, |
+ kLatencyHistogramMax, kLatencyHistogramNumBuckets); |
+ uma_interface.HistogramCustomTimes("Chromoting.Video.RoundTripLatency", |
+ stats->round_trip_ms()->Average(), kLatencyHistogramMin, |
+ kLatencyHistogramMax, kLatencyHistogramNumBuckets); |
} |
// static |