jQ.Mobi VS zepto
JavaScript performance comparison
Info
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
Preparation code
<script src="//zeptojs.com/zepto.min.js">
</script>
<script src="//cdn.jqmobi.com/1.1/jq.mobi.min.js">
</script>
<script src="//ajax.googleapis.com/ajax/libs/jquery/1/jquery.min.js">
</script>
<script src="https://raw.github.com/soyjavi/QuoJS/master/release/quo.js"></script>
<div id="container">
</div>
<script>
Benchmark.prototype.setup = function() {
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;
};
Benchmark.prototype.teardown = function() {
container.innerHTML = "";
};
</script>
Preparation code output
Test runner
Warning! For accurate results, please disable Firebug before running the tests. (Why?)
Java applet disabled.
| Test | Ops/sec | |
|---|---|---|
jQ.Mobi |
|
pending… |
jQuery |
|
pending… |
Zepto |
|
pending… |
Raw JS - Building DOM nodes |
|
pending… |
some jQuery style, native performance with prototypes |
|
pending… |
jq.mobi |
|
pending… |
jq.mobi 2 |
|
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:
- Revision 5: published
- Revision 10: published by Jesse
- Revision 11: published
- Revision 14: published
- Revision 15: published
- Revision 16: published
- Revision 17: published
- Revision 18: published by David Kaneda
- Revision 19: published by Nige White
- Revision 20: published
- Revision 22: published by Nige White
- Revision 24: published by Nige White
- Revision 25: published by fake-or-dead
- Revision 26: published by Praneet Loke
- Revision 27: published by Devin
- Revision 28: published
- Revision 30: published by Praneet Loke
- Revision 31: published by Devin
- Revision 32: published
- Revision 35: published by Devin Rhode
- Revision 37: published by Devin Rhode
- Revision 40: published by Devin Rhode
- Revision 41: published by Devin Rhode
- Revision 43: published
- Revision 44: published
- Revision 45: published
- Revision 49: published
- Revision 50: published
- Revision 51: published
- Revision 52: published by jason mcleod
- Revision 54: published
- Revision 56: published
- Revision 58: published
- Revision 60: published by Keith Chu
- Revision 61: published
- Revision 62: published
- Revision 64: published
- Revision 66: published
- Revision 67: published
- Revision 68: published by levin
- Revision 69: published
- Revision 70: published
- Revision 71: published by Jacob Gable
- Revision 75: published
- Revision 76: published
- Revision 77: published
- Revision 79: published
- Revision 84: published by bill
- Revision 85: published
- Revision 86: published
- Revision 92: published
- Revision 93: published
- Revision 94: published
- Revision 95: published by Kevin
- Revision 97: published
- Revision 102: published by Mark Bradshaw
- Revision 103: published by j79
- Revision 104: published
- Revision 105: published
- Revision 106: published
- Revision 107: published
- Revision 108: published by Marnix T'Jaeckx
- Revision 109: published
- Revision 110: published
- Revision 112: published
- Revision 113: published by Miles Elam
- Revision 114: published by dameleon
- Revision 115: published by realpeterz
- Revision 116: published
- Revision 118: published
- Revision 119: published
- Revision 120: published
- Revision 123: published
- Revision 124: published
- Revision 125: published
- Revision 127: published
- Revision 128: published
- Revision 129: published
- Revision 130: published
- Revision 131: published
0 comments