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 arr = ["GET", "HEAD", "DELETE", "OPTIONS", "TRACE", "CONNECT"];
const set = new Set(arr);
const samples = ["GET", "HEAD", "DELETE", "OPTIONS", "TRACE", "CONNECT", "OTHER"];
const obj = Object.fromEntries(arr.map(q => [q, true]));
function a(method) {
return method === "GET" || method === "HEAD" || method === "DELETE" || method === "OPTIONS" || method === "TRACE" || method === "CONNECT";
}
function b(method) {
return arr.includes(method);
}
function c(method) {
return set.has(method);
}
function d(method) {
const set = new Set(["GET", "HEAD", "DELETE", "OPTIONS", "TRACE", "CONNECT"]);
return set.has(method);
}
function e(method) {
return !!obj[method];
}
function f(method) {
return !!{GET:true,HEAD:true,DELETE:true,OPTIONS:true,TRACE:true,CONNECT:true}[method];
}
function g(method) {
return ["GET", "HEAD", "DELETE", "OPTIONS", "TRACE", "CONNECT"].includes(method);
}
function h(method) {
switch(method) {
case "GET":return "GET";
case "HEAD":return "HEAD";
case "DELETE":return "DELETE";
case "OPTIONS":return "OPTIONS";
case "TRACE":return "TRACE";
case "CONNECT":return "CONNECT";
}
}Ready to run.
| Test | Ops/sec | |
|---|---|---|
| eql: ? | | ready |
| includes: ? | | ready |
| has: ? | | ready |
| inline set has: ? | | ready |
| object: ? | | ready |
| inline object: ? | | ready |
| inline array: ? | | ready |
| switch: ? | | ready |
You can edit these tests or add more tests to this page by appending /edit to the URL.