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

Side by Side 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 unified diff | 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 »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
1 // Copyright 2014 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4
5 #include <math.h>
6
7 #include <algorithm>
8
9 #include "base/strings/stringprintf.h"
10 #include "media/cast/test/utility/test_util.h"
11
12 namespace media {
13 namespace cast {
14 namespace test {
15
16 MeanAndError::MeanAndError(const std::vector<double>& values) {
17 double sum = 0.0;
18 double sqr_sum = 0.0;
19 num_values = values.size();
20 if (num_values) {
21 for (size_t i = 0; i < num_values; i++) {
22 sum += values[i];
23 sqr_sum += values[i] * values[i];
24 }
25 mean = sum / num_values;
26 std_dev =
27 sqrt(std::max(0.0, num_values * sqr_sum - sum * sum)) / num_values;
28 }
29 }
30
31 std::string MeanAndError::AsString() const {
32 return base::StringPrintf("%f +/- %f", mean, std_dev);
33 }
34
35 } // namespace test
36 } // namespace cast
37 } // namespace media
OLDNEW
« 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