index vs parent

JavaScript performance comparison

Test case created

Preparation code

<script src="//ajax.googleapis.com/ajax/libs/jquery/1/jquery.min.js"></script>
<ul class="tabs"><li style="width: 22.5%;"><a href="#tab-0-0" style="height: 15px;">3,000 - 4,999</a><div></div></li><li style="width: 22.5%;"><a href="#tab-0-1" style="height: 15px;">5,000 - 7,499</a><div></div></li><li class="" style="width: 22.5%;"><a href="#tab-0-2" style="height: 15px;">7,500 - 15,000</a><div></div></li><li class="current" style="width: 22.5%;"><a href="#tab-0-3" style="height: 15px;">15,001 - 25,000</a><div></div></li></ul>
<script>
Benchmark.prototype.setup = function() {
    var hash = '#tab-0-1';
};
</script>

Preparation code output

Test runner

Warning! For accurate results, please disable Firebug before running the tests. (Why?)

Java applet disabled.

Testing in unknown unknown
Test Ops/sec
index eq
var index = $('.tabs a', this).index( $('li a[href$="' + hash + '"]') )
if (index !== -1)
{
  $('.tabs a', this).eq(hash_index).trigger('click');
};
pending…
find trigger
$('.tabs', this).find($('a[href$="' + hash + '"]')).trigger('click');
pending…

You can edit these tests or add even more tests to this page by appending /edit to the URL.

Compare results of other browsers

0 comments

Add a comment