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>
var DATA = '{"pewpew": "pewpew", "abc": 157, "aoseuoq": "askdhqio", "a": false}';
var MyObjectLazy = function (url, req, res, path, body) {
this.res = res; // Object
this.req = req; // Object
this.body = body; // String
this.url = url; // Object
this.method = req.method; // String
this.get = url.query; // Object
this.path = path || {}; // Object
this.__defineGetter__("post", function () {
var post = this.body ? JSON.parse(this.body) : {};
delete this.post;
this.post = post;
return post;
});
};
var MyObject = function (url, req, res, path, body) {
this.res = res; // Object
this.req = req; // Object
this.body = body; // String
this.url = url; // Object
this.method = req.method; // String
this.get = url.query; // Object
this.path = path || {}; // Object
this.post = this.body ? JSON.parse(this.body) : {};
};
var MyObjectLazyProto = function (url, req, res, path, body) {
this.res = res; // Object
this.req = req; // Object
this.body = body; // String
this.url = url; // Object
this.method = req.method; // String
this.get = url.query; // Object
this.path = path || {}; // Object
this._post;
};
MyObjectLazyProto.prototype.__defineGetter__("post", function () {
if (this._post) return this._post;
this._post = this.body ? JSON.parse(this.body) : {};
return this._post;
});
var MyObjectLazyProtoDef = function (url, req, res, path, body) {
this.res = res; // Object
this.req = req; // Object
this.body = body; // String
this.url = url; // Object
this.method = req.method; // String
this.get = url.query; // Object
this.path = path || {}; // Object
};
MyObjectLazyProtoDef.prototype.__defineGetter__("post", function () {
var data = this.body ? JSON.parse(this.body) : {};
Object.defineProperty(this, "post", {value : data});
return data;
});
</script>
Ready to run.
Test | Ops/sec | |
---|---|---|
MyObject 50/50 |
| ready |
MyObjectLazy 50/50 |
| ready |
MyObjectLazyProto 50/50 |
| ready |
MyObject 100 |
| ready |
MyObjectLazy 100 |
| ready |
MyObjectLazyProto 100 |
| ready |
MyObjectLazyProtoDef 50/50 |
| ready |
MyObjectLazyProtoDef 100 |
| ready |
You can edit these tests or add more tests to this page by appending /edit to the URL.