This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function generateUser() { | |
var user = {}; | |
user.name = "user-" + Math.floor((Math.random()*1000000)+1); | |
user.imgURL = "http://img-" + Math.floor((Math.random()*1000000)+1); | |
user.posts = []; | |
for (var i=0; i < 10; ++i) { | |
user.posts[i] = { | |
id: Math.floor((Math.random()*1000000)+1), | |
title: "user-" + Math.floor((Math.random()*1000000)+1), | |
contents: "contents-" + Math.floor((Math.random()*1000000)+1) | |
}; | |
} | |
return user; | |
} | |
function timeTest(k, f, n) { | |
var users = []; | |
for (var i=0; i < n; ++i) { | |
users.push(generateUser()); | |
} | |
var start = new Date().getTime(); | |
for (var i=0; i < n; ++i) { | |
document.body.appendChild(f(users[i])); | |
} | |
var stop = new Date().getTime(); | |
console.log(k + " took " + (stop-start)); | |
} | |
timeTest("jQuery", function(u) { return userProfile(u)[0]; }, 1000); | |
timeTest("Dommy", function(u) { return dommy.template_perf_test.user_profile(u); }, 1000); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment