Skip to content

Instantly share code, notes, and snippets.

@kangax
Created February 21, 2009 19:08
Show Gist options
  • Select an option

  • Save kangax/68142 to your computer and use it in GitHub Desktop.

Select an option

Save kangax/68142 to your computer and use it in GitHub Desktop.
var sel = '.shapes li a';
var lim = 100;
console.time('NW');
for (var i=0; i<lim; i++) {
NW.Dom.select(sel);
}
console.timeEnd('NW');
console.time('NW (extended)');
for (var i=0; i<lim; i++) {
Array.map(NW.Dom.select(sel), Element.extend);
}
console.timeEnd('NW (extended)');
console.time('Sizzle');
for (var i=0; i<lim; i++) {
Sizzle(sel)
}
console.timeEnd('Sizzle');
console.time('Sizzle (extended)');
for (var i=0; i<lim; i++) {
Array.map(Sizzle(sel), Element.extend);
}
console.timeEnd('Sizzle (extended)');
console.time('Prototype');
for (var i=0; i<lim; i++) {
$$(sel);
}
console.timeEnd('Prototype');
/*
NW: 31ms
NW (extended): 35ms
Sizzle: 670ms
Sizzle (extended): 674ms
Prototype: 203ms
*/
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment