Created
April 1, 2011 09:16
-
-
Save anonymous/897926 to your computer and use it in GitHub Desktop.
Test to find out the event loop speed.
This file contains 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> | |
<title>Test</title> | |
<script> | |
window.t = null; | |
window.onload = function onLoad() { | |
var runTestFor = 10; | |
var f = 0; | |
window.t = setTimeout(function st() { | |
f++; | |
window.t = setTimeout(st, 0); | |
}, 0); | |
setTimeout(function () { | |
clearTimeout(window.t); | |
var e = document.getElementById('msg'); | |
var fps = f / runTestFor; | |
var delay = (runTestFor*1000) / f; | |
var t = fps+'fps = '+delay+'ms'; | |
e.innerHTML = t; | |
}, runTestFor*1000); | |
} | |
</script> | |
</head> | |
<body> | |
<p id="msg">Running test...</p> | |
</body> | |
</html> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment