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
const types = {
string: 'string',
number: 'number',
object: 'object',
childNodes: 'childNodes',
state: 'state',
function: 'function',
domNode: 'domNode',
unknown: 'unknown',
};
const primitiveTypes = [types.string, types.number];
class Value {
constructor(any, type) {
this._type = type || Value._getType(any);
this._value = any;
}
get value() {
return this._value;
}
is(type) {
return this._type === type;
}
isPrimitive() {
return primitiveTypes.includes(this._value); // todo here is a bug
}
static parse(any) {
const type = Value._getType(any);
return type === types.object
? new Value(parseObject(any), types.childNodes)
: new Value(any, type);
}
static _getType(any) {
const type = typeof any;
if (type === types.object) {
if (any instanceof State) {
return types.state;
}
if (any instanceof Node) {
return types.domNode;
}
}
return type;
}
}
Ready to run.
Test | Ops/sec | |
---|---|---|
Version1 |
| ready |
Version2 |
| ready |
You can edit these tests or add more tests to this page by appending /edit to the URL.