Skip to content

Commit

Permalink
Redefine requestAnimationFrame and setImmediate so that the sp3 bench…
Browse files Browse the repository at this point in the history
…mark captures all the work
  • Loading branch information
julienw committed Feb 15, 2024
1 parent 00651bc commit 1fb190e
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 0 deletions.
10 changes: 10 additions & 0 deletions resources/tentative/todomvc-react-18/dist/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -9,5 +9,15 @@
</head>
<body>
<div id="root"></div>
<script>
// Because the benchmark runner can't easily capture work happening in
// a rAF, let's mock it as a setTimeout instead.
window.requestAnimationFrame = (cb) => window.setTimeout(cb, 0);
// We also define a setImmediate to use a microtask, so that some
// work that wouldn't be captured by our benchmark runner is
// now properly captured. This isn't a perfect polyfill but good
// enough for this workload.
window.setImmediate = window.queueMicrotask;
</script>
</body>
</html>
10 changes: 10 additions & 0 deletions resources/tentative/todomvc-react-18/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,16 @@
</head>
<body>
<div id="root"></div>
<script>
// Because the benchmark runner can't easily capture work happening in
// a rAF, let's mock it as a setTimeout instead.
window.requestAnimationFrame = (cb) => window.setTimeout(cb, 0);
// We also define a setImmediate to use a microtask, so that some
// work that wouldn't be captured by our benchmark runner is
// now properly captured. This isn't a perfect polyfill but good
// enough for this workload.
window.setImmediate = window.queueMicrotask;
</script>
<script type="module" src="/src/main.tsx"></script>
</body>
</html>

0 comments on commit 1fb190e

Please sign in to comment.