function vs regular

JavaScript performance comparison

Test case created by NAIF

Preparation code

<div id="app"></div>
<script>
Benchmark.prototype.setup = function() {
    var doc = document;
    function create(a) { return doc.createElement(a); };
    function id(a) { return doc.getElementById(a); };
};
</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
function
if(id('app').firstChild) id('app').removeChild(id('app').firstChild);
id('app').appendChild(create('span'));
pending…
regular
if(doc.getElementById('app').firstChild) doc.getElementById('app').removeChild(doc.getElementById('app').firstChild);
doc.getElementById('app').appendChild(doc.createElement('span'));
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