/ Published in: jQuery
A way to time how long it takes to get through a certain block of code. Good way to measure performance on the page.
You could also use the built in logging functions in firebug. Not sure how they would tally up in a test.
You could also use the built in logging functions in firebug. Not sure how they would tally up in a test.
Expand |
Embed | Plain Text
Copy this code and paste it in your HTML
$(function(){ console.info("Start Test"); var d = new Date();//Get our start time console.info(d.getSeconds() + " " + d.getMilliseconds()); //Run our test var testBody = ""; for (var i=0; i<1000; i++){ testBody += "<div class='testable"+i+"'>"; } $("body").append(testBody); for (var j=0; j<1000; j++){ $(".testable"+j); } var d = new Date();//Get our end time console.info(d.getSeconds() + " " + d.getMilliseconds()); console.info("End Test"); /** * Console will now log 2 times, the difference between * them is how long the test took to run */ });
URL: http://is.gd/1mhJr