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
<script src="https://cdn.jsdelivr.net/jquery/1.11.1/jquery.min.js"></script>
<script src="https://cdn.jsdelivr.net/mithril/0.1.19/mithril.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/react/0.13.3/react-with-addons.min.js"></script>
<script src="http://cdn.ractivejs.org/latest/ractive.js"></script>
<div id="test"></div>
window.jqTest = function(selector){
var $o = $(selector), id = Math.random();
$o.append("<div id='"+id+"'><h1 id='helloHeader'></h1><form><input type='text' id='name' name='name' value='jq World'/></form></div> ");
$o.find('#helloHeader').html("Hello " + $o.find("input[name=name]").val());
};
// Create React class once only
var H1React = React.createClass({displayName: 'HeaderComponent',
render: function() {
return React.DOM.h1(null, this.props.greeting);
}
});
window.HelloReact = React.createClass({
getInitialState: function() {
return {greeting: ''};
},
setGreeting: function(name) {
this.setState({greeting: "Hello " + name});
},
componentDidMount: function() {
this.setGreeting(this.props.greet);
},
render: function() {
var id = Math.random();
return React.DOM.div({id:id},
H1React({ greeting: this.state.greeting}),
React.DOM.form({},
React.DOM.input({id:"name", name:"name", value: this.props.greet})
));
}
});
// Create Ractive once only as well
window.RactiveComponent = Ractive.extend({
template: "<div id='{{id}}'><h1 id='helloHeader'>{{greeting}}</h1> <form> <input type='text' id='name' name='name' value='{{name}}'/> </form></div>",
data: {
name: "ra World"
},
computed: {
greeting: {
get: function () {
return "Hello " + this.get('name');
}
},
id: {
get: function(){
return Math.random();
}
}
}
});
Ractive.components.ractivecomponent = RactiveComponent;
// Create a mithril app
//
window.MithrilAppFactory = function(){
var ma = {
model: {
name: m.prop("mi World"),
greeting: m.prop("Hello ")
},
controller: function() {
this.model = ma.model;
this.model.greeting(this.model.greeting() + this.model.name());
},
view: function(data) {
var o = data.model, id = Math.random();
return [
m("div", {id:id}, [
m("h1",o.greeting()),
m("form", [
m("input",{value: o.name()})
])
])
];
}
};
return ma;
};
window.nativeTest = function(id){
var rid = Math.random(),
target = document.getElementById(id),
d1 = document.createElement("DIV"),
h1 = document.createElement("H1"),
form = document.createElement("FORM"),
input = document.createElement("INPUT");
d1.setAttribute('id', rid);
input.setAttribute("name", "name");
input.setAttribute("value", "na World");
input.setAttribute("type", "text");
h1.innerHTML = "Hello ";
d1.appendChild(h1);
d1.appendChild(form);
d1.appendChild(input);
h1.innerHTML = h1.innerHTML + input.getAttribute('value');
target.innerHTML = "";
target.appendChild(d1);
};
$("#test").empty()
Ready to run.
Test | Ops/sec | |
---|---|---|
jQuery |
| ready |
React |
| ready |
Ractive |
| ready |
Mithril |
| ready |
Native |
| ready |
You can edit these tests or add more tests to this page by appending /edit to the URL.