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

Unified Diff: chrome/browser/resources/tracing/timeline_model_test.html

Issue 9706010: about:tracing support for TRACE_ASYNC_START/FINISH events. (Closed) Base URL: http://git.chromium.org/chromium/src.git@master
Patch Set: try again 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
Index: chrome/browser/resources/tracing/timeline_model_test.html
diff --git a/chrome/browser/resources/tracing/timeline_model_test.html b/chrome/browser/resources/tracing/timeline_model_test.html
index b95ab0a755a922c48d10384013a1a73169ab8a5b..136211c8cf197fbb1fac4932cf0e72759a0753f1 100644
--- a/chrome/browser/resources/tracing/timeline_model_test.html
+++ b/chrome/browser/resources/tracing/timeline_model_test.html
@@ -18,44 +18,47 @@ found in the LICENSE file.
</head>
<body>
<script>
+'use strict';
var TimelineCpu = tracing.TimelineCpu;
var TimelineSlice = tracing.TimelineSlice;
+var TimelineThreadSlice = tracing.TimelineThreadSlice;
var TimelineProcess = tracing.TimelineProcess;
var TimelineThread = tracing.TimelineThread;
var TimelineModel = tracing.TimelineModel;
+var TimelineAsyncSlice = tracing.TimelineAsyncSlice;
+var TimelineAsyncSliceGroup = tracing.TimelineAsyncSliceGroup;
+
+// Helper function to create a slice.
+function newAsyncSlice(start, duration, startThread, endThread) {
+ var s = new TimelineAsyncSlice('a', 0, start);
+ s.duration = duration;
+ s.startThread = startThread;
+ s.endThread = endThread;
+ return s;
+}
function testThreadBounds_Empty() {
- var t = new TimelineThread(undefined, 1);
+ var t = new TimelineThread(new TimelineProcess(7), 1);
t.updateBounds();
assertEquals(undefined, t.minTimestamp);
assertEquals(undefined, t.maxTimestamp);
}
function testThreadBounds_SubRow() {
- var t = new TimelineThread(undefined, 1);
- t.subRows[0].push(new TimelineSlice('a', 0, 1, {}, 3));
+ var t = new TimelineThread(new TimelineProcess(7), 1);
+ t.subRows[0].push(new TimelineThreadSlice('a', 0, 1, {}, 3));
t.updateBounds();
assertEquals(1, t.minTimestamp);
assertEquals(4, t.maxTimestamp);
}
-function testThreadBounds_NestedSubrow() {
- var t = new TimelineThread(undefined, 1);
- t.nonNestedSubRows.push([]);
- t.nonNestedSubRows[0].push(new TimelineSlice('a', 0, 1, {}, 3));
+function testThreadBounds_AsyncSliceGroup() {
+ var t = new TimelineThread(new TimelineProcess(7), 1);
+ t.subRows[0].push(new TimelineThreadSlice('a', 0, 1, {}, 3));
+ t.asyncSlices.push(newAsyncSlice(0.1, 5, t, t));
t.updateBounds();
- assertEquals(1, t.minTimestamp);
- assertEquals(4, t.maxTimestamp);
-}
-
-function testThreadBounds_SubRowAndNonNestedSubRow() {
- var t = new TimelineThread(undefined, 1);
- t.subRows[0].push(new TimelineSlice('a', 0, 0.5, {}, 3));
- t.nonNestedSubRows.push([]);
- t.nonNestedSubRows[0].push(new TimelineSlice('b', 0, 1, {}, 4.5));
- t.updateBounds();
- assertEquals(0.5, t.minTimestamp);
- assertEquals(5.5, t.maxTimestamp);
+ assertEquals(0.1, t.minTimestamp);
+ assertEquals(5.1, t.maxTimestamp);
}
function testModelBounds_EmptyModel() {
@@ -73,10 +76,10 @@ function testModelBounds_OneEmptyThread() {
assertEquals(undefined, m.maxTimestamp);
}
-function testModelBounds_OneThrad() {
+function testModelBounds_OneThread() {
var m = new TimelineModel();
var t = m.getOrCreateProcess(1).getOrCreateThread(1);
- t.subRows[0].push(new TimelineSlice('a', 0, 1, {}, 3));
+ t.subRows[0].push(new TimelineThreadSlice('a', 0, 1, {}, 3));
m.updateBounds();
assertEquals(1, m.minTimestamp);
assertEquals(4, m.maxTimestamp);
@@ -85,7 +88,7 @@ function testModelBounds_OneThrad() {
function testModelBounds_OneThreadAndOneEmptyThread() {
var m = new TimelineModel();
var t1 = m.getOrCreateProcess(1).getOrCreateThread(1);
- t1.subRows[0].push(new TimelineSlice('a', 0, 1, {}, 3));
+ t1.subRows[0].push(new TimelineThreadSlice('a', 0, 1, {}, 3));
var t2 = m.getOrCreateProcess(1).getOrCreateThread(1);
m.updateBounds();
assertEquals(1, m.minTimestamp);
@@ -99,7 +102,6 @@ function testCpuBounds_Empty() {
assertEquals(undefined, cpu.maxTimestamp);
}
-
function testCpuBounds_OneSlice() {
var cpu = new TimelineCpu(undefined, 1);
cpu.slices.push(new TimelineSlice('a', 0, 1, {}, 3));
@@ -109,16 +111,120 @@ function testCpuBounds_OneSlice() {
}
function testModelBounds_OneCpu() {
+ var m = new TimelineModel();
+ var cpu = m.getOrCreateCpu(1);
+ cpu.slices.push(new TimelineSlice('a', 0, 1, {}, 3));
+ m.updateBounds();
+ assertEquals(1, m.minTimestamp);
+ assertEquals(4, m.maxTimestamp);
}
function testModelBounds_OneCpuOneThread() {
+ var m = new TimelineModel();
+ var cpu = m.getOrCreateCpu(1);
+ cpu.slices.push(new TimelineSlice('a', 0, 1, {}, 3));
+
+ var t = m.getOrCreateProcess(1).getOrCreateThread(1);
+ t.subRows[0].push(new TimelineThreadSlice('a', 0, 1, {}, 4));
+
+ m.updateBounds();
+ assertEquals(1, m.minTimestamp);
+ assertEquals(5, m.maxTimestamp);
+}
+
+function testPTIDFromPidAndTid() {
+ assertEquals('1:2', TimelineThread.getPTIDFromPidAndTid(1, 2));
+}
+
+function testAsyncSliceGroupBounds_Empty() {
+ var g = new TimelineAsyncSliceGroup(name);
+ g.updateBounds();
+ assertEquals(undefined, g.minTimestamp);
+ assertEquals(undefined, g.maxTimestamp);
+}
+
+function testAsyncSliceGroupBounds_Basic() {
+ var p1 = new TimelineProcess(1);
+ var t1 = new TimelineThread(p1, 1);
+ var g = new TimelineAsyncSliceGroup('a');
+ g.push(newAsyncSlice(0, 1, t1, t1));
+ g.push(newAsyncSlice(1, 1.5, t1, t1));
+ assertEquals(2, g.length);
+ g.updateBounds();
+ assertEquals(0, g.minTimestamp);
+ assertEquals(2.5, g.maxTimestamp);
+}
+
+function testAsyncSliceGroup_rebuildSubRows_twoNonOverlappingSlices() {
+ var p1 = new TimelineProcess(1);
+ var t1 = new TimelineThread(p1, 1);
+ var g = new TimelineAsyncSliceGroup('a');
+ g.slices.push(newAsyncSlice(0, 1, t1, t1));
+ g.slices.push(newAsyncSlice(1, 1, t1, t1));
+
+ assertEquals(1, g.subRows.length);
+ assertEquals(2, g.subRows[0].length);
+ assertEquals(g.slices[0], g.subRows[0][0]);
+ assertEquals(g.slices[1], g.subRows[0][1]);
+}
+
+function testAsyncSliceGroup_rebuildSubRows_twoOverlappingSlices() {
+ var p1 = new TimelineProcess(1);
+ var t1 = new TimelineThread(p1, 1);
+ var g = new TimelineAsyncSliceGroup('a');
+ g.slices.push(newAsyncSlice(0, 1, t1, t1));
+ g.slices.push(newAsyncSlice(0, 1.5, t1, t1));
+ g.updateBounds();
+
+ assertEquals(2, g.subRows.length);
+ assertEquals(1, g.subRows[0].length);
+ assertEquals(g.slices[0], g.subRows[0][0]);
+ assertEquals(1, g.subRows[1].length);
+ assertEquals(g.slices[1], g.subRows[1][0]);
+}
+
+function testAsyncSliceGroup_rebuildSubRows_threePartlyOverlappingSlices() {
+ var p1 = new TimelineProcess(1);
+ var t1 = new TimelineThread(p1, 1);
+ var g = new TimelineAsyncSliceGroup('a');
+ g.slices.push(newAsyncSlice(0, 1, t1, t1));
+ g.slices.push(newAsyncSlice(0, 1.5, t1, t1));
+ g.slices.push(newAsyncSlice(1, 1.5, t1, t1));
+ g.updateBounds();
+
+ assertEquals(2, g.subRows.length);
+ assertEquals(2, g.subRows[0].length);
+ assertEquals(g.slices[0], g.subRows[0][0]);
+ assertEquals(g.slices[2], g.subRows[0][1]);
+ assertEquals(1, g.subRows[1].length);
+ assertEquals(g.slices[1], g.subRows[1][0]);
+}
+
+function testAsyncSliceGroup_computeSubGroups_twoThreadSpecificSlices() {
+ var p1 = new TimelineProcess(1);
+ var t1 = new TimelineThread(p1, 1);
+ var t2 = new TimelineThread(p1, 2);
+ var g = new TimelineAsyncSliceGroup('a');
+ g.slices.push(newAsyncSlice(0, 1, t1, t1));
+ g.slices.push(newAsyncSlice(0, 1, t2, t2));
+
+ var subGroups = g.computeSubGroups();
+ assertEquals(2, subGroups.length);
+
+ assertEquals(g.name, subGroups[0].name);
+ assertEquals(1, subGroups[0].slices.length);
+ assertEquals(g.slices[0], subGroups[0].slices[0]);
+
+ assertEquals(g.name, subGroups[1].name);
+ assertEquals(1, subGroups[1].slices.length);
+ assertEquals(g.slices[1], subGroups[1].slices[0]);
}
function testModelCanImportEmpty() {
var m;
m = new TimelineModel([]);
- m = new TimelineModel("");
+ m = new TimelineModel('');
}
</script>
</body>
« no previous file with comments | « chrome/browser/resources/tracing/timeline_model.js ('k') | chrome/browser/resources/tracing/timeline_test.html » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698