Skip to content

Instantly share code, notes, and snippets.

@longouyang
Created June 18, 2010 19:41
Show Gist options
  • Save longouyang/444107 to your computer and use it in GitHub Desktop.
Save longouyang/444107 to your computer and use it in GitHub Desktop.
<html>
<head>
<script type="text/javascript">
var pID;
var i = 0;
var startTime, endTime;
function start_test() {
i = 0;
pID = setInterval(update, 1);
startTime = new Date();
}
function update() {
i++;
if(i == 250) {
end();
}
}
function end() {
clearInterval(pID);
endTime = new Date();
document.getElementById('result').innerHTML = (endTime-startTime) / 250 + "ms";
}
</script>
</head>
<body>
This test assesses how fast setInterval() is called.
<input type="submit" onclick="start_test();" value="Start">
<div id='result'></div>
</body></html>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment