Qwery vs JQuery2.0 vs Minimal

JavaScript performance comparison

Revision 30 of this test case created by polikis

Info

Tests handling the most basic selectors between qwery, sizzle, and minimal. Qwery and sizzle are both wonderful, but minimal is for those who want to always use only the most performant selectors. It forces you to do this by limiting the kinds of selectors it will treat. For instance, descendants are not allowed (e.g. '#parent #child'), nor css3 selectors, which is significantly slower than id, tag, or class (that is where getElementsByClassName is supported). qwery and sizzle will prefer these fast methods, but will do more checks and function calls. The ambition behind minimal is to create the fastest selector engine possible, even if it can't do everything.

Preparation code

<script src="http://code.jquery.com/jquery-2.0.3.js"></script>
<script src="https://rawgithub.com/ded/qwery/master/qwery.js"></script>
<script src="https://rawgithub.com/timmywil/minimal/master/src/minimal.js"></script>
<div foo="bar"></div>
<div class="a"></div>
<div id="boosh">
  <div class="a b">
    <div class="d e" test="fg" id="booshTest"></div>
    <em test="f g"></em>
    <span class="h i a"></span>
  </div>
</div>
<div id="attr-test1"></div>
<div id="attr-test2"></div>
<div id="attr-test3" class="found you" title="whatup duders"></div>
<script>
  Benchmark.count = 0;
  Benchmark.prototype.setup = function() {
   var Q = qwery,
       S = $,
       QA = queryAll
  };
</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
Qwery .d
Q('.d');
pending…
Sizzle .d
S('.d');
pending…
Minimal .d
QA('.d');
pending…
Qwery #boosh
Q('#boosh')
pending…
Sizzle #boosh
S('#boosh')
pending…
Minimal #boosh
QA('#boosh')
pending…
Query div
Q('div')
pending…
Sizzle div
S('div')
pending…
Minimal div
QA('div')
pending…
Qwery div.a
Q('div.a')
pending…
Sizzle div.a
S('div.a')
pending…
Minimal div.a
QA('div.a')
pending…
Qwery div.a, .d
Q('div.a, .d')
pending…
Sizzle div.a, .d
S('div.a, .d')
pending…
Minimal div.a, .d
QA('div.a, .d')
pending…
Qwery .noexist
Q('.noexist')
pending…
Sizzle .noexist
S('.noexist')
pending…
Minimal .noexist
QA('.noexist')
pending…
Qwery #noexist
Q('#noexist')
pending…
Sizzle #noexist
S('#noexist')
pending…
Minimal #noexist
QA('#noexist')
pending…
Qwery [title]
Q('[title]')
pending…
Sizzle [title]
S('[title]')
pending…
Minimal [title]
QA('[title]')
pending…

Compare results of other browsers

Revisions

You can edit these tests or add even more tests to this page by appending /edit to the URL. Here’s a list of current revisions for this page:

0 comments

Add a comment