OLD | NEW |
| (Empty) |
1 <html> | |
2 <head> | |
3 <script src="../../http/tests/inspector/inspector-test.js"></script> | |
4 <script src="../../http/tests/inspector/timeline-test.js"></script> | |
5 <script src="../tracing-test.js"></script> | |
6 <script> | |
7 | |
8 function simplePerformanceMeasure() | |
9 { | |
10 performance.mark("a-start"); | |
11 performance.mark("a-end"); | |
12 performance.measure("a", "a-start", "a-end"); | |
13 } | |
14 | |
15 function nestedPerformanceMeasure() | |
16 { | |
17 performance.mark("a-start"); | |
18 { | |
19 performance.mark("b-start"); | |
20 performance.mark("b-end"); | |
21 { | |
22 performance.mark("c-start"); | |
23 { | |
24 performance.mark("d-start"); | |
25 performance.mark("d-end"); | |
26 } | |
27 performance.mark("c-end"); | |
28 } | |
29 } | |
30 performance.mark("a-end"); | |
31 performance.measure("a", "a-start", "a-end"); | |
32 performance.measure("b", "b-start", "b-end"); | |
33 performance.measure("c", "c-start", "c-end"); | |
34 performance.measure("d", "d-start", "d-end"); | |
35 } | |
36 | |
37 | |
38 function unbalancedPerformanceMeasure() | |
39 { | |
40 performance.mark("a-start"); | |
41 performance.mark("b-start"); | |
42 performance.mark("a-end"); | |
43 performance.mark("b-end"); | |
44 performance.measure("a", "a-start", "a-end"); | |
45 performance.measure("b", "b-start", "b-end"); | |
46 } | |
47 | |
48 | |
49 function parentMeasureIsOnTop() | |
50 { | |
51 performance.mark("startTime1"); | |
52 performance.mark("endTime1"); | |
53 | |
54 performance.mark("startTime2"); | |
55 performance.mark("endTime2"); | |
56 | |
57 performance.measure("durationTime1", "startTime1", "endTime1"); | |
58 performance.measure("durationTime2", "startTime2", "endTime2"); | |
59 performance.measure("durationTimeTotal", "startTime1", "endTime2"); | |
60 } | |
61 | |
62 | |
63 function test() | |
64 { | |
65 InspectorTest.runTestSuite([ | |
66 function testSimplePerformanceMeasure(next) | |
67 { | |
68 performActions("simplePerformanceMeasure()", next); | |
69 }, | |
70 | |
71 function testNestedPerformanceMeasure(next) | |
72 { | |
73 performActions("nestedPerformanceMeasure()", next); | |
74 }, | |
75 | |
76 function testUnbalancedPerformanceMeasure(next) | |
77 { | |
78 performActions("unbalancedPerformanceMeasure()", next); | |
79 }, | |
80 | |
81 function testParentMeasureIsOnTop(next) | |
82 { | |
83 performActions("parentMeasureIsOnTop()", next); | |
84 } | |
85 ]); | |
86 | |
87 function dumpUserTimings() | |
88 { | |
89 var model = InspectorTest.timelineModel(); | |
90 var asyncEvents = model.mainThreadAsyncEvents() | |
91 | |
92 asyncEvents.forEach(function(eventGroup) { | |
93 eventGroup.forEach(function(event) { | |
94 if (event.hasCategory(WebInspector.TimelineModel.Category.UserTi
ming)) | |
95 InspectorTest.addResult(event.name); | |
96 }); | |
97 }) | |
98 } | |
99 | |
100 function performActions(actions, next) | |
101 { | |
102 InspectorTest.evaluateWithTimeline(actions, _ => { dumpUserTimings(); ne
xt(); }); | |
103 | |
104 } | |
105 } | |
106 | |
107 </script> | |
108 </head> | |
109 | |
110 <body onload="runTest()"> | |
111 <p>Test performance.mark/measure records on Timeline</p> | |
112 | |
113 </body> | |
114 </html> | |
OLD | NEW |