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

Unified Diff: tracing/tracing/metrics/system_health/cpu_time_metric_test.html

Issue 2351963006: Add range of interest support to cpuTimeMetric. (Closed)
Patch Set: Add test, comments, etc. Created 4 years, 3 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 | « tracing/tracing/metrics/system_health/cpu_time_metric.html ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: tracing/tracing/metrics/system_health/cpu_time_metric_test.html
diff --git a/tracing/tracing/metrics/system_health/cpu_time_metric_test.html b/tracing/tracing/metrics/system_health/cpu_time_metric_test.html
index 1866e69e8185c1fae01dd3286a98f76660861be0..65616512ea8bcdecf03ffb84d96cce981f520c5d 100644
--- a/tracing/tracing/metrics/system_health/cpu_time_metric_test.html
+++ b/tracing/tracing/metrics/system_health/cpu_time_metric_test.html
@@ -13,12 +13,12 @@ found in the LICENSE file.
'use strict';
tr.b.unittest.testSuite(function() {
- function computeCpuTime(customizeModelCallback) {
+ function computeCpuTime(customizeModelCallback, opt_options) {
var model = tr.c.TestUtils.newModel(function(model) {
customizeModelCallback(model);
});
var values = new tr.v.ValueSet();
- tr.metrics.sh.cpuTimeMetric(values, model);
+ tr.metrics.sh.cpuTimeMetric(values, model, opt_options);
return tr.b.getOnlyElement(values).average;
}
@@ -47,7 +47,37 @@ tr.b.unittest.testSuite(function() {
cpuDuration: sliceDuration,
}));
});
- assert.closeTo(value, 33.33, 0.1);
+ assert.closeTo(value, 0.033, 0.001);
+ });
+
+ // Makes sure that rangeOfInterest works correctly.
+ test('cpuTimeMetric_oneProcess_rangeOfInterest', function() {
+ var sliceDuration = 50;
+ var totalDuration = 3000;
+ var rangeOfInterest = new tr.b.Range.fromExplicitRange(-10, 30);
+ var options = {}
+ options.rangeOfInterest = rangeOfInterest
+ var value = computeCpuTime(function(model) {
+ model.rendererProcess = model.getOrCreateProcess(2);
+ model.rendererMain = model.rendererProcess.getOrCreateThread(3);
+ model.rendererMain.sliceGroup.pushSlice(tr.c.TestUtils.newSliceEx({
+ type: tr.model.ThreadSlice,
+ isTopLevel: true,
+ start: 0,
+ duration: sliceDuration,
+ cpuStart: 0,
+ cpuDuration: sliceDuration,
+ }));
+ model.rendererMain.sliceGroup.pushSlice(tr.c.TestUtils.newSliceEx({
+ type: tr.model.ThreadSlice,
+ isTopLevel: true,
+ start: totalDuration - sliceDuration,
+ duration: sliceDuration,
+ cpuStart: totalDuration - sliceDuration,
+ cpuDuration: sliceDuration,
+ }));
+ }, options);
+ assert.closeTo(value, 0.75, 0.001);
});
// Process 1: There are two slices, each of length 50. The total bounds is
@@ -87,7 +117,7 @@ tr.b.unittest.testSuite(function() {
cpuDuration: sliceDuration,
}));
});
- assert.closeTo(value, 50.0, 0.1);
+ assert.closeTo(value, 0.05, 0.001);
});
});
</script>
« no previous file with comments | « tracing/tracing/metrics/system_health/cpu_time_metric.html ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698