Skip to content

Commit 1fb190e

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

File tree

2 files changed

+20
-0
lines changed

2 files changed

+20
-0
lines changed

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

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,5 +9,15 @@
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. This isn't a perfect polyfill but good
19+
// enough for this workload.
20+
window.setImmediate = window.queueMicrotask;
21+
</script>
1222
</body>
1323
</html>

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

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,16 @@
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. This isn't a perfect polyfill but good
17+
// enough for this workload.
18+
window.setImmediate = window.queueMicrotask;
19+
</script>
1020
<script type="module" src="/src/main.tsx"></script>
1121
</body>
1222
</html>

0 commit comments

Comments
 (0)