Skip to content

Instantly share code, notes, and snippets.

Created April 1, 2011 09:16
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save anonymous/897926 to your computer and use it in GitHub Desktop.
Save anonymous/897926 to your computer and use it in GitHub Desktop.
Test to find out the event loop speed.
<!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