Project Description

After reading http://ejohn.org/blog/accuracy-of-javascript-time/ I decided to make a simple IE wrapper that expose throught the window.external interface an high resolution timer for testing IE Javascript performance

The project will be a very basic .net 3.5 window forms project written with VS 2008 express,
it will require .net 3.5 installed.

How it works?

The IE JST browser expose 2 function thought the window.external interface
so instead of using the getDate() method you now will use

window.external.startBench();
and
window.external.stopBench();

the 2nd method will return the elapsed milliseconds from the last call of startBench as a string

The form include a RichTextBox console in with it output the elapsed time with the resolution of 1/10 of millisecond.

Simply drag your testing page in the browser window to start the test.

Know Bugs

If your pc have more that 1 processor the test could be strange, that's because I internally use the Stopwatch object that work only if the same thread start and stop the timer.
If the first line in the console is "Operations timed using the DateTime class." your system doesn't support the high-resolution timer, so the result will be the same as using the getDate() method (accuracy +/- ~15ms)

Suggestions

Some people suggest to open windows media player (w/out playing anything) before starting the test
I reccomend to throw out the first result to skip the warmout error, so if you need a 10000 cycles test, do a 10001 cycles test and start to test from the 2 loop ;)
Pressing F5 reload your test so you don't have to re-drag the file on the browser window ;)

Example page

<html>
<script>
onload=function(){
window.external.startBench();
var final = 0;
for(var i=0,max=1000;i<max;i++)
for(var j=0,jmax=1000;j<jmax;j++) final ++;
document.body.innerHTML += final;
alert(window.external.stopBench());
}
</script>
<body>
</body>
</html>

Last edited Nov 16, 2008 at 10:25 AM by kentaromiura, version 4