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

Unified Diff: tracing/tracing/extras/chrome/cpu_time_test.html

Issue 2804693005: Getting segments for rail stage and initiator (Closed)
Patch Set: Address comments by tdresser@ Created 3 years, 7 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/extras/chrome/cpu_time.html ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: tracing/tracing/extras/chrome/cpu_time_test.html
diff --git a/tracing/tracing/extras/chrome/cpu_time_test.html b/tracing/tracing/extras/chrome/cpu_time_test.html
index 73220e63b8352c7de2de4566ffa44d56cf1542c7..177e2732653d2663910288bfbcb3b4890ec2ac27 100644
--- a/tracing/tracing/extras/chrome/cpu_time_test.html
+++ b/tracing/tracing/extras/chrome/cpu_time_test.html
@@ -12,6 +12,11 @@ found in the LICENSE file.
'use strict';
tr.b.unittest.testSuite(function() {
+ const getStageToInitiatorToSegmentBounds =
+ tr.e.chrome.cpuTime.getStageToInitiatorToSegmentBounds;
+
+ const INITIATOR_TYPE = tr.model.um.INITIATOR_TYPE;
+
test('getCpuTimeForThread', () => {
const model = tr.c.TestUtils.newModel(function(model) {
const thread = model.getOrCreateProcess(1).getOrCreateThread(1);
@@ -41,5 +46,119 @@ tr.b.unittest.testSuite(function() {
assert.closeTo(tr.e.chrome.cpuTime.getCpuTimeForThread(thread, bounds),
expectedCpuTime, 1e-7);
});
+
+ test('getStageToInitiatorToSegmentBounds', () => {
+ const model = tr.c.TestUtils.newModel(function(model) {
+ const thread = model.getOrCreateProcess(1).getOrCreateThread(1);
+ // This is needed for a model to have segments.
+ thread.name = 'CrBrowserMain';
+
+ model.userModel.expectations.push(new tr.model.um.AnimationExpectation(
+ model, INITIATOR_TYPE.CSS,
+ 100, // start time.
+ 300 // duration.
+ ));
+ model.userModel.expectations.push(new tr.model.um.AnimationExpectation(
+ model, INITIATOR_TYPE.VIDEO, 300, 100));
+ model.userModel.expectations.push(new tr.model.um.ResponseExpectation(
+ model, INITIATOR_TYPE.SCROLL, 400, 200));
+ });
+
+ const segments = model.userModel.segments;
+
+ const map = getStageToInitiatorToSegmentBounds(
+ model.userModel.segments, model.bounds);
+
+ // Ignoring Idle Expectations, we have the following segments:
+ // [100, 300]: CSS Animation
+ // [300, 400]: CSS Animation, Video Animation
+ // [400, 600]: Scroll Response
+ const allSegments = [...map.get('all_stages').get('all_initiators')];
+ assert.sameDeepMembers(
+ allSegments.map(s => [s.min, s.max]),
+ [[100, 300], [300, 400], [400, 600]]);
+
+ const videoAnimationSegments =
+ [...map.get('Animation').get(INITIATOR_TYPE.VIDEO)];
+ assert.sameDeepMembers(
+ videoAnimationSegments.map(s => [s.min, s.max]),
+ [[300, 400]]);
+
+ const cssAnimationSegments =
+ [...map.get('Animation').get(INITIATOR_TYPE.CSS)];
+ assert.sameDeepMembers(
+ cssAnimationSegments.map(s => [s.min, s.max]),
+ [[100, 300], [300, 400]]);
+
+ const allAnimationSegments =
+ [...map.get('Animation').get('all_initiators')];
+ assert.sameDeepMembers(
+ allAnimationSegments.map(s => [s.min, s.max]),
+ [[100, 300], [300, 400]]);
+
+ const scrollResponseSegments =
+ [...map.get('Response').get(INITIATOR_TYPE.SCROLL)];
+ assert.sameDeepMembers(
+ scrollResponseSegments.map(s => [s.min, s.max]),
+ [[400, 600]]);
+
+ const allResponseSegments =
+ [...map.get('Response').get('all_initiators')];
+ assert.sameDeepMembers(
+ allResponseSegments.map(s => [s.min, s.max]),
+ [[400, 600]]);
+ });
+
+ test('getStageToInitiatorToSegmentBounds-rangeOfInterest', () => {
+ const model = tr.c.TestUtils.newModel(function(model) {
+ const thread = model.getOrCreateProcess(1).getOrCreateThread(1);
+ // This is needed for a model to have segments.
+ thread.name = 'CrBrowserMain';
+
+ model.userModel.expectations.push(new tr.model.um.AnimationExpectation(
+ model, INITIATOR_TYPE.CSS,
+ 100, // start time.
+ 300 // duration.
+ ));
+ model.userModel.expectations.push(new tr.model.um.AnimationExpectation(
+ model, INITIATOR_TYPE.VIDEO, 300, 100));
+ model.userModel.expectations.push(new tr.model.um.ResponseExpectation(
+ model, INITIATOR_TYPE.SCROLL, 400, 200));
+ });
+
+ const segments = model.userModel.segments;
+
+ const map = getStageToInitiatorToSegmentBounds(model.userModel.segments,
+ tr.b.math.Range.fromExplicitRange(150, 350));
+
+ // Ignoring Idle Expectations, we have the following segments in range:
+ // [150, 300]: CSS Animation
+ // [300, 350]: CSS Animation, Video Animation
+ const allSegments = [...map.get('all_stages').get('all_initiators')];
+ assert.sameDeepMembers(
+ allSegments.map(s => [s.min, s.max]),
+ [[150, 300], [300, 350]]);
+
+ const videoAnimationSegments =
+ [...map.get('Animation').get(INITIATOR_TYPE.VIDEO)];
+ assert.sameDeepMembers(
+ videoAnimationSegments.map(s => [s.min, s.max]),
+ [[300, 350]]);
+
+ const cssAnimationSegments =
+ [...map.get('Animation').get(INITIATOR_TYPE.CSS)];
+ assert.sameDeepMembers(
+ cssAnimationSegments.map(s => [s.min, s.max]),
+ [[150, 300], [300, 350]]);
+
+ const allAnimationSegments =
+ [...map.get('Animation').get('all_initiators')];
+ assert.sameDeepMembers(
+ allAnimationSegments.map(s => [s.min, s.max]),
+ [[150, 300], [300, 350]]);
+
+ // There should be no Response segments
+ assert.isFalse(map.has('Response'));
+ });
});
</script>
« no previous file with comments | « tracing/tracing/extras/chrome/cpu_time.html ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698