Skip to content

Commit 12875ea

Browse files
committed
Redefine requestAnimationFrame and setImmediate so that the sp3 benchmark captures all the work
1 parent 00651bc commit 12875ea

File tree

2 files changed

+22
-0
lines changed

2 files changed

+22
-0
lines changed

resources/tentative/todomvc-react-18/dist/index.html

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,5 +9,16 @@
99
</head>
1010
<body>
1111
<div id="root"></div>
12+
<script>
13+
// Because the benchmark runner can't easily capture work happening in
14+
// a rAF, let's mock it as a setTimeout instead.
15+
window.requestAnimationFrame = (cb) => window.setTimeout(cb, 0);
16+
// We also define a setImmediate to use a microtask, so that some
17+
// work that wouldn't be captured by our benchmark runner is
18+
// now properly captured.
19+
window.setImmediate = (cb) => {
20+
Promise.resolve().then(() => cb());
21+
};
22+
</script>
1223
</body>
1324
</html>

resources/tentative/todomvc-react-18/index.html

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,17 @@
77
</head>
88
<body>
99
<div id="root"></div>
10+
<script>
11+
// Because the benchmark runner can't easily capture work happening in
12+
// a rAF, let's mock it as a setTimeout instead.
13+
window.requestAnimationFrame = (cb) => window.setTimeout(cb, 0);
14+
// We also define a setImmediate to use a microtask, so that some
15+
// work that wouldn't be captured by our benchmark runner is
16+
// now properly captured.
17+
window.setImmediate = (cb) => {
18+
Promise.resolve().then(() => cb());
19+
};
20+
</script>
1021
<script type="module" src="/src/main.tsx"></script>
1122
</body>
1223
</html>

0 commit comments

Comments
 (0)