Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(294)

Unified Diff: media/cast/test/utility/test_util.cc

Issue 308713005: Cast: Synthetic benchmark tool. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: merge + minor fix Created 6 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « media/cast/test/utility/test_util.h ('k') | media/cast/test/utility/udp_proxy.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: media/cast/test/utility/test_util.cc
diff --git a/media/cast/test/utility/test_util.cc b/media/cast/test/utility/test_util.cc
new file mode 100644
index 0000000000000000000000000000000000000000..461a1729d1277e27e794c99b9b42da4308932b48
--- /dev/null
+++ b/media/cast/test/utility/test_util.cc
@@ -0,0 +1,37 @@
+// Copyright 2014 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#include <math.h>
+
+#include <algorithm>
+
+#include "base/strings/stringprintf.h"
+#include "media/cast/test/utility/test_util.h"
+
+namespace media {
+namespace cast {
+namespace test {
+
+MeanAndError::MeanAndError(const std::vector<double>& values) {
+ double sum = 0.0;
+ double sqr_sum = 0.0;
+ num_values = values.size();
+ if (num_values) {
+ for (size_t i = 0; i < num_values; i++) {
+ sum += values[i];
+ sqr_sum += values[i] * values[i];
+ }
+ mean = sum / num_values;
+ std_dev =
+ sqrt(std::max(0.0, num_values * sqr_sum - sum * sum)) / num_values;
+ }
+}
+
+std::string MeanAndError::AsString() const {
+ return base::StringPrintf("%f +/- %f", mean, std_dev);
+}
+
+} // namespace test
+} // namespace cast
+} // namespace media
« no previous file with comments | « media/cast/test/utility/test_util.h ('k') | media/cast/test/utility/udp_proxy.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698