Skip to content

Instantly share code, notes, and snippets.

@bttmly
Created October 11, 2014 17:25
Show Gist options
  • Save bttmly/c934404e96cfd3af6569 to your computer and use it in GitHub Desktop.
Save bttmly/c934404e96cfd3af6569 to your computer and use it in GitHub Desktop.
poser push benchmark
function grabIt (thing) {
var frame = document.createElement('iframe');
document.body.appendChild(frame);
var thing = frame.contentWindow[thing];
document.body.removeChild(frame);
return thing;
}
var Collection = grabIt("Array");
var c = new Collection();
var a = new Array();
function push1000 (arr) {
var i = -1;
while (++i < 1000) {
arr.push(i);
}
}
console.time('col');
push1000(c);
console.timeEnd('col');
console.time('arr');
push1000(a);
console.timeEnd('arr');
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment