Skip to content

Instantly share code, notes, and snippets.

@subzey
Created January 10, 2022 15:13
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
Star You must be signed in to star a gist
Save subzey/30d069bf4eb7b537311c7e9a3b2b9c6b to your computer and use it in GitHub Desktop.
fillText bench
<!doctype html>
<html>
<head></head>
<body>
<p><output></output></p>
<canvas width="1920" height="1080"></canvas>
<script>
const c = document.querySelector('canvas').getContext('2d');
const out = document.querySelector('output');
requestAnimationFrame(function frame() {
const start = performance.now();
for (let x = 0; x < 1920; x += 10) {
for (let y = 0; y < 1080; y += 10) {
c.fillText(' ', x, y);
}
}
const elapsed = Math.round(performance.now() - start);
out.textContent = elapsed + 'ms';
requestAnimationFrame(frame);
});
</script>
</body>
</html>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment