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

Unified Diff: chrome/browser/performance_monitor/performance_monitor_util.cc

Issue 10860017: Refactor Metrics (Closed) Base URL: http://git.chromium.org/chromium/src.git@master
Patch Set: Nitfix + latest master for cq Created 8 years, 4 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
Index: chrome/browser/performance_monitor/performance_monitor_util.cc
diff --git a/chrome/browser/performance_monitor/performance_monitor_util.cc b/chrome/browser/performance_monitor/performance_monitor_util.cc
index 2ef0ea06d97ba9f7206650d34c63879b3f8be933..5caeddffde371197266ed91ea88ef3e58a4b84b5 100644
--- a/chrome/browser/performance_monitor/performance_monitor_util.cc
+++ b/chrome/browser/performance_monitor/performance_monitor_util.cc
@@ -9,23 +9,21 @@
#include "base/string_number_conversions.h"
#include "base/threading/sequenced_worker_pool.h"
#include "base/time.h"
-#include "chrome/browser/performance_monitor/database.h"
#include "chrome/browser/performance_monitor/events.h"
#include "content/public/browser/browser_thread.h"
namespace performance_monitor {
namespace util {
-std::vector<MetricInfo> AggregateMetric(
- const std::vector<MetricInfo>& metric_infos,
- const base::Time& start,
- const base::TimeDelta& resolution) {
- std::vector<MetricInfo> results;
+Database::MetricVector AggregateMetric(const Database::MetricVector& metrics,
+ const base::Time& start,
+ const base::TimeDelta& resolution) {
+ Database::MetricVector results;
// Ignore all the points before the aggregation start.
- std::vector<MetricInfo>::const_iterator it = metric_infos.begin();
- for (; it != metric_infos.end() && it->time < start; ++it) { }
+ Database::MetricVector::const_iterator it = metrics.begin();
+ for (; it != metrics.end() && it->time < start; ++it) { }
- while (it != metric_infos.end()) {
+ while (it != metrics.end()) {
// Finds the beginning of the next aggregation window.
int64 window_offset = (it->time - start) / resolution;
base::Time window_start = start + (window_offset * resolution);
@@ -34,21 +32,21 @@ std::vector<MetricInfo> AggregateMetric(
double integrated = 0.0;
double metric_value = 0.0;
- // Aggregate the step function defined by the MetricInfos in |metric_infos|.
- while (it != metric_infos.end() && it->time <= window_end) {
+ // Aggregate the step function defined by the Metrics in |metrics|.
+ while (it != metrics.end() && it->time <= window_end) {
metric_value = it->value;
integrated += metric_value * (it->time - last_sample_time).InSecondsF();
last_sample_time = it->time;
++it;
}
- if (it != metric_infos.end())
+ if (it != metrics.end())
metric_value = it->value;
// If the window splits an area of the step function, split the aggregation
// at the end of the window.
integrated += metric_value * (window_end - last_sample_time).InSecondsF();
double average = integrated / resolution.InSecondsF();
- results.push_back(MetricInfo(window_end, average));
+ results.push_back(Metric(window_end, average));
}
return results;
}

Powered by Google App Engine
This is Rietveld 408576698