Return to Snippet

Revision: 37077
at December 3, 2010 09:31 by tirams


Initial Code
var loops = 1000;

console.time('simple'); 
for(i = 0; i < loops; i++){
    var x = $('option[value=valInField]');
} 
console.timeEnd('simple')

console.time('selectorcontext'); 
for(i = 0; i < loops; i++){
    var x = $('#critRow_0 option[value=valInField]');
} 
console.timeEnd('selectorcontext')

console.time('findcontext1'); 
var context = $('#critRow_0');
for(i = 0; i < loops; i++){
    var x = context.find('option[value=valInField]');
} 
console.timeEnd('findcontext1')

console.time('findcontext2'); 
for(i = 0; i < loops; i++){
    var x = $('#critRow_0').find('option[value=valInField]');
} 
console.timeEnd('findcontext2')

console.time('contextparm'); 
var ctx = $('#critRow_0')[0];
for(i = 0; i < loops; i++){
    var x = $('option[value=valInField]', ctx);
} 
console.timeEnd('contextparm')

console.log("1. " + context.find('option[value=valInField]').length);
console.log("2. " + $('#critRow_0 option[value=valInField]').length);
console.log("3. " + $('#critRow_0').find('option[value=valInField]').length);
console.log("4. " + $('option[value=valInField]', ctx).length );

Initial URL

                                

Initial Description
jquery performance test see also http://jsbin.com/aciji4/12

Initial Title
jquery performance test selectors

Initial Tags
jquery

Initial Language
jQuery