mirror of
https://github.com/mollyim/webrtc.git
synced 2025-05-15 14:50:39 +01:00

Also, add more tests to perf_test_unittest. Bug: webrtc:8566 Change-Id: I8864db7172fa207803d310c4a5fee4bf820a56bd Reviewed-on: https://webrtc-review.googlesource.com/25823 Reviewed-by: Fredrik Solenberg <solenberg@webrtc.org> Reviewed-by: Henrik Lundin <henrik.lundin@webrtc.org> Reviewed-by: Patrik Höglund <phoglund@webrtc.org> Commit-Queue: Edward Lemur <ehmaldonado@webrtc.org> Cr-Commit-Position: refs/heads/master@{#20906}
92 lines
3.1 KiB
C++
92 lines
3.1 KiB
C++
/*
|
|
* Copyright (c) 2012 The WebRTC project authors. All Rights Reserved.
|
|
*
|
|
* Use of this source code is governed by a BSD-style license
|
|
* that can be found in the LICENSE file in the root of the source
|
|
* tree. An additional intellectual property rights grant can be found
|
|
* in the file PATENTS. All contributing project authors may
|
|
* be found in the AUTHORS file in the root of the source tree.
|
|
*/
|
|
|
|
// A stripped-down version of Chromium's chrome/test/perf/perf_test.cc.
|
|
// ResultsToString(), PrintResult(size_t value) and AppendResult(size_t value)
|
|
// have been modified. The remainder are identical to the Chromium version.
|
|
|
|
#include "test/testsupport/perf_test.h"
|
|
|
|
#include <sstream>
|
|
#include <stdio.h>
|
|
#include <vector>
|
|
|
|
namespace {
|
|
|
|
void PrintResultsImpl(const std::string& graph_name,
|
|
const std::string& trace,
|
|
const std::string& values,
|
|
const std::string& units,
|
|
bool important) {
|
|
// <*>RESULT <graph_name>: <trace_name>= <value> <units>
|
|
// <*>RESULT <graph_name>: <trace_name>= {<mean>, <std deviation>} <units>
|
|
// <*>RESULT <graph_name>: <trace_name>= [<value>,value,value,...,] <units>
|
|
|
|
if (important) {
|
|
printf("*");
|
|
}
|
|
printf("RESULT %s: %s= %s %s\n", graph_name.c_str(), trace.c_str(),
|
|
values.c_str(), units.c_str());
|
|
}
|
|
|
|
} // namespace
|
|
|
|
namespace webrtc {
|
|
namespace test {
|
|
|
|
void PrintResult(const std::string& measurement,
|
|
const std::string& modifier,
|
|
const std::string& trace,
|
|
const double value,
|
|
const std::string& units,
|
|
bool important) {
|
|
std::ostringstream value_stream;
|
|
value_stream << value;
|
|
PrintResultsImpl(measurement + modifier, trace, value_stream.str(), units,
|
|
important);
|
|
}
|
|
|
|
void PrintResultMeanAndError(const std::string& measurement,
|
|
const std::string& modifier,
|
|
const std::string& trace,
|
|
const double mean,
|
|
const double error,
|
|
const std::string& units,
|
|
bool important) {
|
|
std::ostringstream value_stream;
|
|
value_stream << '{' << mean << ',' << error << '}';
|
|
PrintResultsImpl(measurement + modifier, trace, value_stream.str(), units,
|
|
important);
|
|
}
|
|
|
|
void PrintResultList(const std::string& measurement,
|
|
const std::string& modifier,
|
|
const std::string& trace,
|
|
const std::vector<double>& values,
|
|
const std::string& units,
|
|
bool important) {
|
|
std::ostringstream value_stream;
|
|
value_stream << '[';
|
|
if (!values.empty()) {
|
|
auto it = values.begin();
|
|
while (true) {
|
|
value_stream << *it;
|
|
if (++it == values.end())
|
|
break;
|
|
value_stream << ',';
|
|
}
|
|
}
|
|
value_stream << ']';
|
|
PrintResultsImpl(measurement + modifier, trace, value_stream.str(), units,
|
|
important);
|
|
}
|
|
|
|
} // namespace test
|
|
} // namespace webrtc
|