Skip to content

Instantly share code, notes, and snippets.

@aria42
Created April 28, 2013 15:45
  • Star 2 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
Star You must be signed in to star a gist
Save aria42/91988c4e5a67c460dd2a to your computer and use it in GitHub Desktop.
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