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
function creator(type) {
const Action = function Action(value) {
return {
type,
value,
};
};
// @ts-expect-error ignore this
Action.inputs = [];
Action.addInput = function addInput(input) {
Action.inputs.push(input);
};
return Action;
}
class Traversable {
inputs = [];
constructor(type) {
this.type = type;
}
value(val) {
this.val = val;
}
addInput(input) {
this.inputs.push(input);
}
}
class TypedAction {
inputs = [];
constructor(value) {
this.value = value;
}
addInput(input) {
this.inputs.push(input);
}
}
function classInFn(typed) {
class MyAction extends TypedAction {
type = typed;
}
return MyAction;
}
function classInFn2(typed){
function MyAction(value){
this.inputs = [];
this.value = value;
}
MyAction.type = typed;
MyAction.prototype.addInput = function addInput(input){
this.inputs.push(input);
}
return MyAction;
}
class Creator {
inputs = [];
constructor(type){
this.type = type;
}
addInput(input){
this.inputs.push(input);
}
}
class ActionBase {
constructor(creator){
this.creator = creator;
}
setValue(val){
this.value = val;
return this;
}
}
class MyAction extends ActionBase {
static type = 'test';
}
function mixed(classType){
const creator = new Creator(classType.type);
return function (){
return new classType(creator);
}
}
class MyActionSelf {
static creator = new Creator('test');
constructor(val){
this.value = val;
}
}
class ActionSelf {
isAction = true;
}
class MyActionSelfSuper extends ActionSelf {
static creator = new Creator('test');
constructor(val){
super();
this.value = val;
}
}
let result;
Ready to run.
Test | Ops/sec | |
---|---|---|
fn |
| ready |
extend (class in fn) |
| ready |
class |
| ready |
mixed classfn |
| ready |
self |
| ready |
self super |
| ready |
class in fn 2 |
| ready |
You can edit these tests or add more tests to this page by appending /edit to the URL.