querySelectorAll vs getElementById (v75)

Revision 75 of this benchmark created by Andrey Kindin on


Preparation HTML

<p id="foo">bar</p>

Setup

var select = function(query){
  	if (query[0] == "#"){
  		return document.getElementById(query.slice(1));
  	}else{
  		return document.querySelectorAll(query);
  	}
  };

Test runner

Ready to run.

Testing in
TestOps/sec
getElementById
var result = document.getElementById('foo');
ready
querySelectorAll
var result = document.querySelectorAll('#foo');
ready
select
var result = select("#foo");
ready

Revisions

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