[ Kubissimo_ @ 14.11.2010. 15:14 ] @
save as speedTest.html Code: <?xml version="1.0" encoding="UTF-8"?> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en"> <head> <title>browser speed test</title><!-- version 2.1 --> <meta name="author" content="Kubissimo_"/> <meta name="ROBOTS" content="NOINDEX, NOFOLLOW"/> <meta http-equiv="content-type" content="application/xhtml+xml; charset=UTF-8"/> <meta http-equiv="content-type" content="text/html; charset=UTF-8"/> <meta http-equiv="content-style-type" content="text/css"/> <style type="text/css"> body { margin: 0px; background-color: #FFFFFF; color: #333333; font-family: sans-serif; font-size: small; } table { border: 12px solid #EEEEFF; padding: 7px 7px 0px 7px; text-align: right; } .input { width: 170px; text-align: right; } #displayBrowser { width: 728px; background-color: #FFFFCC; } #displayTotal { background-color: #FFFFCC; } </style> <script type="text/javascript"> // <!-- window.onload = function() { document.getElementById("displayBrowser").value = navigator.userAgent; }; var pre = new Array(48); var loaded = 0; for (var i=0; i<48; i++) { pre[i] = new Image(62, 62); pre[i].id = "pre_"+i; pre[i].src = "http://hscripts.com/" + "freeimages/icons/clipart/cube/cube-icon-picture"+(i+1)+".gif"; pre[i].onload = function() {loaded++;}; } function preLoadImages() { document.getElementById("preLoadImages").disabled = true; if (loaded < 48) { window.setTimeout("preLoadImages();", 333); return; } document.getElementById("performSpeedTest1").disabled = false; document.getElementById("displayTotal").value = "ready!? "; } var startTime = 0; function performSpeedTest1() { document.getElementById("performSpeedTest1").disabled = true; startTime = new Date().getTime(); for (var i=0; i<12*12; i++) { for (var j=0; j<12; j++) { if (i >= 4) { var newImg = document.createElement("img"); newImg.id = "pre_"+(i*12+j); newImg.src = pre[(i*12+j)%48].src; document.getElementById("testingAppendChild").appendChild(newImg); } else { document.getElementById("testingAppendChild").appendChild(pre[i*12+j]); } } document.getElementById("testingAppendChild").appendChild(document.createElement("br")); } stopTime(1); } function performSpeedTest2() { var test = new String(); for (var i=0; i<12*12; i++) { for (var j=0; j<12; j++) { test += '<img id="pre_'+(12*12+i*12+j)+'" src="'+pre[(i*12+j)%48].src+'" width="62" height="62" border="0" alt=""/>'; } test += "<br/>"; } document.getElementById("testingInnerHTML").innerHTML = test; stopTime(2); } function performSpeedTest3() { for (var i=0; i<12*12*12*12; i++) { getDistance(Math.random(), Math.random(), Math.random(), Math.random()); } stopTime(3); document.getElementById("reloadSpeedTest").disabled = false; } var total = 0; function stopTime(num) { window.setTimeout(function() { var endTime = new Date().getTime(); var result = (endTime - startTime) + " milliseconds"; total += (endTime - startTime); document.getElementById("displayTest"+num).value = result; startTime = endTime; if (num == 1) { performSpeedTest2(); } else if (num == 2) { performSpeedTest3(); } else if (num == 3) { document.getElementById("displayTotal").value = "total = "+total+" milliseconds"; } }, 0); } function getDistance(ax, ay, bx, by) { return Math.sqrt(Math.pow(bx-ax, 2) + Math.pow(by-ay, 2)); } function reloadSpeedTest() { window.location.href = window.location.href; } // --> </script> </head> <body> <table> <tr> <td colspan="4"><input id="displayBrowser" type="text" value="loading..."/></td> </tr> <tr> <td><input id="reloadSpeedTest" class="input" type="button" disabled="disabled" value="reload speed test" onclick="reloadSpeedTest();"/></td> <td><input id="preLoadImages" class="input" type="button" value="preload images" onclick="preLoadImages();"/></td> <td><input id="performSpeedTest1" class="input" type="button" disabled="disabled" value="perform speed test" onclick="performSpeedTest1();"/></td> <td><input id="displayTotal" class="input" type="text" value="hello legend! "/></td> </tr> <tr> <td colspan="3">testing: DOM methods: createElement('img'), appendChild(imgObject)</td> <td><input id="displayTest1" class="input" type="text" value=""/></td> </tr> <tr> <td colspan="3">testing: String object: str += str2; DOM manipulation: innerHTML = str</td> <td><input id="displayTest2" class="input" type="text" value=""/></td> </tr> <tr> <td colspan="3">testing: Math object: Math.pow(x, y), Math.sqrt(z), and Math.random()</td> <td><input id="displayTest3" class="input" type="text" value=""/></td> </tr> <tr> <td colspan="4"><div id="testingAppendChild"></div></td> </tr> <tr> <td colspan="4"><div id="testingInnerHTML"></div></td> </tr> </table> </body> </html> [Ovu poruku je menjao Kubissimo_ dana 15.11.2010. u 18:22 GMT+1] |