This page tests the speed of JavaScript. It loops through a series of computations as well as some array and string manipulations and keeps track of the time it takes. This is perhaps a little more "real world" than the original JavaScript Speed Test.
letters = new Array("a","b","c","d","e","f","g","h","i","j","k","l","m","n","o","p","q","r","s","t","u","v","w","x","y","z"); colors = new Array("red","blue","green","orange","purple","yellow","brown","black","white","gray"); function doTest() { sob = document.forms[0].timeStart; eob = document.forms[0].timeEnd; dob = document.forms[0].timeDiff; rob = document.forms[0].results; // clear values sob.value = ""; eob.value = ""; dob.value = ""; rob.value = ""; nob = new Date(); start = nob.getTime(); sob.value = nob.toUTCString(); // do some math for (i=0;i<1000;i++) { tmp = Math.round(i*Math.SQRT1_2); addResult(tmp); } // do some strings and array stuff for (j=0;j<colors.length;j++) { fav = "My favorite color is " + colors[j] + ".\n"; addResult(fav); favArray = fav.split(" "); for (l=0;l<favArray.length;l++) { addResult(favArray[l]); } } // do some more strings and array stuff for (k=0;k<1000;k++) { // make up email address name = makeName(8); email = name + "@mac.com"; addResult(email); } nob = new Date(); end = nob.getTime(); eob.value = nob.toUTCString(); dob.value = (end - start)/1000; } function makeName(n) { tmp = ""; for (i=0;i<n;i++) { l = Math.floor(26*Math.random()); tmp += letters[l]; } return tmp; } function addResult(r) { rob.value += "\n" + r; } |