1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
|
<!DOCTYPE HTML>
<meta charset=utf-8>
<title>PerformanceObservers: mark and measure</title>
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<script src="performanceobservers.js"></script>
<h1>PerformanceObservers: mark and measure</h1>
<p>
Performance.mark() and Performance.measure() will <a href="https://w3c.github.io/performance-timeline/#dfn-queue-a-performanceentry">queue a PerformanceEntry</a>.
</p>
<div id="log"></div>
<script>
async_test(function (t) {
var stored_entries = [];
var observer = new PerformanceObserver(
t.step_func(function (entryList, obs) {
stored_entries =
stored_entries.concat(entryList.getEntries());
if (stored_entries.length >= 4) {
checkEntries(stored_entries,
[{ entryType: "mark", name: "mark1"},
{ entryType: "mark", name: "mark2"},
{ entryType: "measure", name: "measure1"},
{ entryType: "measure", name: "measure2"}]);
observer.disconnect();
t.done();
}
})
);
observer.observe({entryTypes: ["mark", "measure"]});
}, "entries are observable");
async_test(function (t) {
var mark_entries = [];
var observer = new PerformanceObserver(
t.step_func(function (entryList, obs) {
mark_entries =
mark_entries.concat(entryList.getEntries());
if (mark_entries.length >= 2) {
checkEntries(mark_entries,
[{ entryType: "mark", name: "mark1"},
{ entryType: "mark", name: "mark2"}]);
observer.disconnect();
t.done();
}
})
);
observer.observe({entryTypes: ["mark"]});
performance.mark("mark1");
performance.mark("mark2");
}, "mark entries are observable");
async_test(function (t) {
var measure_entries = [];
var observer = new PerformanceObserver(
t.step_func(function (entryList, obs) {
measure_entries =
measure_entries.concat(entryList.getEntries());
if (measure_entries.length >= 2) {
checkEntries(measure_entries,
[{ entryType: "measure", name: "measure1"},
{ entryType: "measure", name: "measure2"}]);
observer.disconnect();
t.done();
}
})
);
observer.observe({entryTypes: ["measure"]});
performance.measure("measure1");
performance.measure("measure2");
}, "measure entries are observable");
</script>
|