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 test case focuses solely on pattern variations of creating a "Class".
No work is done in each case, just access, leaving the 'perf' to be determined by which pattern creates it's "Class" fastest.
Sometimes, less is more.
<script>
//Assign 'KlassX' Pattern to 'tmp' in each test
var tmp;
//
// Prototypal
//
function Klass1 () {}
Klass1.prototype = {
foo : function () {},
bar : function () {}
};
//
// Module Pattern
//
function Klass2 () {
return {
foo: function() {},
bar: function() {}
};
}
//
// Module Pattern Utilizing Cached Functions
//
var functionFoo = function() {},
functionBar = function() {};
function Klass3 () {
return {
foo: functionFoo,
bar: functionBar
};
}
</script>
Ready to run.
Test | Ops/sec | |
---|---|---|
Prototypal |
| ready |
Module Pattern |
| ready |
Module Pattern Utilizing Cached Functions |
| ready |
You can edit these tests or add more tests to this page by appending /edit to the URL.