SelectorSet#matches

JavaScript performance comparison

Test case created by Joshua Peek

Preparation code

<div id="foo" class="bar" lang="en"></div>

<script src="http://josh.github.io/selector-set/selector-set.js"></script>
<script>
var foo = document.getElementById("foo");

var emptySet = new SelectorSet();

var fooSet = new SelectorSet();
fooSet.add("#foo");

var fooBarSet = new SelectorSet();
fooBarSet.add("#foo");
fooBarSet.add(".bar");

var midFooSet = new SelectorSet();
midFooSet.add("#foo");
midFooSet.add("#bar");
midFooSet.add("#baz");
midFooSet.add("#qux");
midFooSet.add(".foo");
midFooSet.add(".bar");
midFooSet.add(".baz");
midFooSet.add(".qux");
midFooSet.add("foo");
midFooSet.add("bar");
midFooSet.add("baz");
midFooSet.add("qux");
</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
empty set matches
emptySet.matches(foo);
pending…
#foo matches
SelectorSet.matches(foo, "#foo");
pending…
#foo set matches
fooSet.matches(foo);
pending…
#foo.bar matches
SelectorSet.matches(foo, "#foo");
SelectorSet.matches(foo, ".bar");
pending…
#foo.bar set matches
fooBarSet.matches(foo);
pending…
mid-size matches
SelectorSet.matches(foo, "#foo");
SelectorSet.matches(foo, "#bar");
SelectorSet.matches(foo, "#baz");
SelectorSet.matches(foo, "#qux");
SelectorSet.matches(foo, ".foo");
SelectorSet.matches(foo, ".bar");
SelectorSet.matches(foo, ".baz");
SelectorSet.matches(foo, ".qux");
SelectorSet.matches(foo, "foo");
SelectorSet.matches(foo, "bar");
SelectorSet.matches(foo, "baz");
SelectorSet.matches(foo, "qux");
pending…
mid-size set matches
midFooSet.matches(foo);
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