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
Compare performance of the better-dom library and jquery and now mootools in typical cases
<script src="//ajax.googleapis.com/ajax/libs/jquery/2.0.2/jquery.js"></script>
<script src="//rawgithub.com/chemerisuk/better-dom/v1.2.0/better-dom.js"></script>
<script src="//ajax.googleapis.com/ajax/libs/mootools/1.4.5/mootools-yui-compressed.js"></script>
<script>
/*
---
script: Elements.From.js
name: Elements.From
description: Returns a collection of elements from a string of html.
license: MIT-style license
authors:
- Aaron Newton
- adapted by Graeme Yeates
requires:
- Core/String
- Core/Element
- /MooTools.More
provides: [Elements.from, Elements.From]
...
*/
window.addEvent("domready", function(){
function tableFix(match, text) {
var container = new Element('table');
var tag = match[1].toLowerCase();
if (['td', 'th', 'tr'].contains(tag)){
container = new Element('tbody').inject(container);
if (tag != 'tr') container = new Element('tr').inject(container);
}
return container.set('html', text).getChildren();
}
var table_re = /^\s*<(t[dhr]|tbody|tfoot|thead)/i;
var range = document.createRange();
if(range.createContextualFragment) {
var reference = document.getElement("div");
range.selectNode(reference);
Elements.from2 = function(text, excludeScripts) {
if (excludeScripts || excludeScripts == null) text = text.stripScripts();
var match = text.match(table_re);
if(match) return tableFix(match,text);
var elements = range.createContextualFragment(text).childNodes;
return new Elements(elements);
};
} else { //fall back for ie<9
Elements.from2 = function(text, excludeScripts){
if (excludeScripts || excludeScripts == null) text = text.stripScripts();
var match = text.match(table_re);
if(match) return tableFix(match,text);
return new Element('div').set('html', text).getChildren();
};
}
});
/*
---
script: Elements.From.js
name: Elements.From
description: Returns a collection of elements from a string of html.
license: MIT-style license
authors:
- Aaron Newton
requires:
- Core/String
- Core/Element
- /MooTools.More
provides: [Elements.from, Elements.From]
...
*/
Elements.from = function(text, excludeScripts){
if (excludeScripts || excludeScripts == null) text = text.stripScripts();
var container, match = text.match(/^\s*(?:<!--.*?-->\s*)*<(t[dhr]|tbody|tfoot|thead)/i);
if (match){
container = new Element('table');
var tag = match[1].toLowerCase();
if (['td', 'th', 'tr'].contains(tag)){
container = new Element('tbody').inject(container);
if (tag != 'tr') container = new Element('tr').inject(container);
}
}
return (container || new Element('div')).set('html', text).getChildren();
};
</script>
var short = "<span>Short test string</span>"
var normal = "<a id='a1' rel='b2'><span>Couple eles to parse </span><i>through</i></a>"
var long = '<footer><a href="/">Add test</a> · <a href="/browse">Latest</a> · <a href="/popular">Popular</a> · <a href="/faq">FAQ</a> · <a href="/faq#donate">Donate</a> · <a href="//twitter.com/jsperf" rel="nofollow">twitter: @jsperf</a> · <a href="https://github.com/mathiasbynens/jsperf.com">source on GitHub</a> · <a href="//benchmarkjs.com/">Benchmark.js</a> · by <a href="//mathiasbynens.be/">@mathias</a> and <a href="/contributors">contributors</a></footer>'
Ready to run.
Test | Ops/sec | |
---|---|---|
jquery#create(HtmlString) |
| ready |
DOM#create(HtmlString) |
| ready |
Element.from(html str) |
| ready |
Elements.from2(html str) |
| ready |
You can edit these tests or add more tests to this page by appending /edit to the URL.