jsPerf.app is an online JavaScript performance benchmark test runner & jsperf.com mirror. It is a complete rewrite in homage to the once excellent jsperf.com now with hopefully a more modern & maintainable codebase.
jsperf.com URLs are mirrored at the same path, e.g:
https://jsperf.com/negative-modulo/2
Can be accessed at:
https://jsperf.app/negative-modulo/2
This is an edited test from http://jsperf.com/jqm3/26 by @DevinRhode2
I added a raw JS baseline, and another test that uses javascript prototypes to create some jquery-like abstraction, but yield nearly the same performance as raw JS. This makes one consider the Prototype javascript library. In attempting to add the Prototype version, I decided that it's too different, even as a pretty well versed javascript developer.
From: http://api.prototypejs.org/dom/Element/new/, a Prototype test case would look something like this:
var ul = new Element('ul').update("<li>Hello PrototypeJS world, you're strange.");
.update? .text or .innerText are far too commonplace, and .update truly threw me for a second. PrototypeJS is great, but I'd rather see a jQ.Mobi re-write that heavily uses prototypes of native objects. By my investigation on their docs site, prototypes don't seem modified at all. I'm curious about the feasibility of a jQ.Mobi re-write that heavily uses prototypes
<script src="//zeptojs.com/zepto.min.js">
</script>
<script src="//cdn.jqmobi.com/jq.mobi.min.js">
</script>
<script src="//ajax.googleapis.com/ajax/libs/jquery/1/jquery.min.js">
</script>
<div id="container">
</div>
var d = {};
d.id = function(el) {
return document.getElementById(el);
}
d.create = function(el) {
return document.createElement(el);
}
//Lets add the append method to all html dom nodes:
HTMLElement.prototype.append = function(el) {
this.appendChild(el);
}
var container = d.id('container');
var ul, li, i = 0;
container.innerHTML = "";
Ready to run.
Test | Ops/sec | |
---|---|---|
jQ.Mobi |
| ready |
jQuery |
| ready |
Zepto |
| ready |
Raw JS - Building DOM nodes |
| ready |
some jQuery style, native performance with prototypes |
| ready |
jq.mobi |
| ready |
jq.mobi 2 |
| ready |
You can edit these tests or add more tests to this page by appending /edit to the URL.