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

Unified Diff: base/test/trace_event_analyzer.cc

Issue 9580021: Add test for RAF-spinning with no damage (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: marking test flaky for initial commit to be safe Created 8 years, 9 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 | « base/test/trace_event_analyzer.h ('k') | base/test/trace_event_analyzer_unittest.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: base/test/trace_event_analyzer.cc
diff --git a/base/test/trace_event_analyzer.cc b/base/test/trace_event_analyzer.cc
index db1de4ca695239159f0afa4195469e379fdf95fe..ac4968c95b45eb4654395403973ea12987703a64 100644
--- a/base/test/trace_event_analyzer.cc
+++ b/base/test/trace_event_analyzer.cc
@@ -817,16 +817,18 @@ void TraceAnalyzer::ParseMetadata() {
// TraceEventVector utility functions.
-bool GetRateStats(const TraceEventVector& events, RateStats* stats) {
+bool GetRateStats(const TraceEventVector& events,
+ RateStats* stats,
+ const RateStatsOptions* options) {
CHECK(stats);
// Need at least 3 events to calculate rate stats.
- if (events.size() < 3) {
+ const size_t kMinEvents = 3;
+ if (events.size() < kMinEvents) {
LOG(ERROR) << "Not enough events: " << events.size();
return false;
}
std::vector<double> deltas;
- double delta_sum = 0.0;
size_t num_deltas = events.size() - 1;
for (size_t i = 0; i < num_deltas; ++i) {
double delta = events.at(i + 1)->timestamp - events.at(i)->timestamp;
@@ -835,9 +837,24 @@ bool GetRateStats(const TraceEventVector& events, RateStats* stats) {
return false;
}
deltas.push_back(delta);
- delta_sum += delta;
}
+ std::sort(deltas.begin(), deltas.end());
+
+ if (options) {
+ if (options->trim_min + options->trim_max > events.size() - kMinEvents) {
+ LOG(ERROR) << "Attempt to trim too many events";
+ return false;
+ }
+ deltas.erase(deltas.begin(), deltas.begin() + options->trim_min);
+ deltas.erase(deltas.end() - options->trim_max, deltas.end());
+ }
+
+ num_deltas = deltas.size();
+ double delta_sum = 0.0;
+ for (size_t i = 0; i < num_deltas; ++i)
+ delta_sum += deltas[i];
+
stats->min_us = *std::min_element(deltas.begin(), deltas.end());
stats->max_us = *std::max_element(deltas.begin(), deltas.end());
stats->mean_us = delta_sum / static_cast<double>(num_deltas);
« no previous file with comments | « base/test/trace_event_analyzer.h ('k') | base/test/trace_event_analyzer_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698