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>
const message = 'Error message';
const category = 'Error category';
const level = 'info';
const stack = 'erro stack, erro stack, erro stack';
const customData = {
tag1: 'tag1',
tag2: 'tag2',
};
class ExtendsError extends Error {
constructor(message, category, stack, customData, level) {
super(message); // 调用父类的构造函数
this.category = category;
this.stack = stack;
this.customData = customData;
this.level = level;
}
}
function FuncPrototype(message, category, stack, customData, level) {
this.message = message;
this.category = category;
this.stack = stack;
this.customData = customData;
this.level = level;
}
FuncPrototype.prototype = Error.prototype;
class NormalClass {
constructor(message, category, stack, customData, level) {
this.message = message;
this.category = category;
this.stack = stack;
this.customData = customData;
this.level = level;
}
}
function FuncClass(message, category, stack, customData, level) {
this.message = message;
this.category = category;
this.stack = stack;
this.customData = customData;
this.level = level;
}
function assert(err, iof) {
if (iof == null && !(err instanceof Error)) {
throw 'not instanceof Error';
}
if (err.message !== message) {
throw 'err.message asset failed';
}
if (err.stack !== stack) {
throw 'err.stack asset failed';
}
if (err.category !== category) {
throw 'err.category asset failed';
}
if (err.customData.tag1 !== customData.tag1 || err.customData.tag2 !== customData.tag2) {
throw 'err.customData asset failed';
}
if (err.level !== level) {
throw 'err.level asset failed';
}
}
</script>
Ready to run.
Test | Ops/sec | |
---|---|---|
extends Error |
| ready |
function prototype |
| ready |
Object.create |
| ready |
normal class |
| ready |
function class |
| ready |
Object.create object |
| ready |
You can edit these tests or add more tests to this page by appending /edit to the URL.