Skip to content

Commit 7832cf6

Browse files
committed
Add nested perf measures example
1 parent d0be595 commit 7832cf6

File tree

4 files changed

+73
-0
lines changed

4 files changed

+73
-0
lines changed

index.html

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@
3030
<li><a href="many-redirects/index.html">many-redirects</a></li>
3131
<li><a href="minified-with-source-maps/index.html">minified-with-source-maps</a></li>
3232
<li><a href="nested-interactions/index.html">nested-interactions</a></li>
33+
<li><a href="nested-user-timings/index.html">nested-user-timings</a></li>
3334
<li><a href="node-fib-app/index.html">node-fib-app</a></li>
3435
<li><a href="react-hello-world/index.html">react-hello-world</a></li>
3536
<li><a href="scheduler/index.html">scheduler</a></li>

nested-user-timings/README.md

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
# user-timings
2+
3+
This example creates some performance measures:
4+
5+
1. `first measure` from 0-200ms
6+
2. `second measure` from 0-600ms
7+
3. `third measure` from 1000-2000ms

nested-user-timings/app.js

Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
1+
function consecutiveNonOverlapping() {
2+
const name = 'ConsecutiveNonOverlapping';
3+
const start = performance.now();
4+
5+
performance.measure(name, {
6+
start: start,
7+
end: start + 500,
8+
});
9+
performance.measure(name, {
10+
start: start + 500,
11+
end: start + 1000,
12+
});
13+
}
14+
15+
function overlappingNonNested() {
16+
const name = 'OverlappingNonNested';
17+
const start = performance.now();
18+
19+
performance.measure(name, {
20+
start: start,
21+
end: start + 500,
22+
});
23+
performance.measure(name, {
24+
start: start + 100,
25+
end: start + 600,
26+
});
27+
}
28+
29+
function overlappingNested() {
30+
const name = 'OverlappingNested';
31+
const start = performance.now();
32+
33+
performance.measure(name, {
34+
start: start,
35+
end: start + 500,
36+
});
37+
performance.measure(name, {
38+
start: start + 100,
39+
end: start + 200,
40+
});
41+
}
42+
43+
setTimeout(() => {
44+
consecutiveNonOverlapping();
45+
}, 100);
46+
47+
setTimeout(() => {
48+
overlappingNonNested();
49+
}, 2000);
50+
51+
setTimeout(() => {
52+
overlappingNested();
53+
54+
const text = document.createTextNode('Finished!');
55+
document.body.appendChild(text);
56+
}, 3000);

nested-user-timings/index.html

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
<html>
2+
<head>
3+
<title>User Timings</title>
4+
<style></style>
5+
</head>
6+
<body>
7+
<script src="app.js"></script>
8+
</body>
9+
</html>

0 commit comments

Comments
 (0)