This sets up API to release OutputSurface from LTHClient.
[chromium-blink-merge.git] / media / cast / test / utility / test_util.cc
blob461a1729d1277e27e794c99b9b42da4308932b48
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.
5 #include <math.h>
7 #include <algorithm>
9 #include "base/strings/stringprintf.h"
10 #include "media/cast/test/utility/test_util.h"
12 namespace media {
13 namespace cast {
14 namespace test {
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];
25 mean = sum / num_values;
26 std_dev =
27 sqrt(std::max(0.0, num_values * sqr_sum - sum * sum)) / num_values;
31 std::string MeanAndError::AsString() const {
32 return base::StringPrintf("%f +/- %f", mean, std_dev);
35 } // namespace test
36 } // namespace cast
37 } // namespace media