Created
January 10, 2022 15:13
-
-
Save subzey/30d069bf4eb7b537311c7e9a3b2b9c6b to your computer and use it in GitHub Desktop.
fillText bench
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!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