JavaScript Speed Test 1.0



This page tests the speed of JavaScript. It loops through a series of computations and keeps track of the time it takes. Pretty simple.

New: I put together a new and improved JavaScript Speed Test 2.0! This one does string and array manipulation in addition to math for a more "realistic" evaluation. The results are pretty much the same, though. :-) If you have suggestions for improving on these tests, I'd love to hear them!

Start Time:

End Time:

Time Difference (seconds):

Computation Results:

  
function doTest()
{
   sob = document.forms[0].timeStart;
   eob = document.forms[0].timeEnd;
   dob = document.forms[0].timeDiff;
   rob = document.forms[0].results;

   nob   = new Date();
   start = nob.getTime();
   sob.value = nob.toUTCString();

   for (i=0;i<500;i++)
   {
	  tmp = Math.sqrt(i);
	  addResult(tmp);

	  tmp = Math.sqrt(Math.SQRT1_2);
	  addResult(tmp);

	  tmp = Math.floor(i*Math.random());
	  addResult(tmp);
   }

   nob = new Date();
   end = nob.getTime();
   eob.value = nob.toUTCString();

   dob.value = (end - start)/1000;
}

function addResult(r)
{
   rob.value += "\n" + r;
}
Was this page useful to you? Loading...