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 src="https://cdnjs.cloudflare.com/ajax/libs/underscore.js/1.13.6/underscore-min.js"></script>
const smallNumericArray = [0.1, 0.25, 0.5, 0.75, 1, 1.5, 2, 3, 4, 5, 8, 10];
const numericThreshold = 1;
const numericPredicate = (val) => val > numericThreshold;
const numericPredicateInverse = (val) => val < numericThreshold;
const stringArray = [
"APPLE",
"ORANGE",
"BANANA",
"GRAPE",
"MANGO",
"PINEAPPLE",
"STRAWBERRY",
];
const stringToExclude = "ORANGE";
const stringPredicate = (color) => color !== stringToExclude;
const objectArraySize = 100;
const objectArray = [];
const orientations = [
"center",
"top",
"bottom",
"left",
"right",
"top-left",
"top-right",
];
for (let i = 0; i < objectArraySize; i++) {
objectArray.push({
id: `id_${i}`,
token: `token_${i % 10}`, // Simulate filtering out specific tokens
type: i % 5 === 0 ? "special" : "regular",
value: Math.random() * 100,
active: i % 3 === 0,
orientation: orientations[i % orientations.length],
matches: {
// Simulating label.enforceOrientation
center: i % orientations.length === 0,
top: i % orientations.length === 1,
bottom: i % orientations.length === 2,
},
// Method simulation
isActive: function () {
return this.active;
},
isSpecificType: function (t) {
return this.type === t;
},
});
}
const specificTokenToExclude = "token_3";
const objectIdPredicate = (item) => item.token !== specificTokenToExclude;
const specificOrientation = "center";
const objectOrientationPredicate = (item) =>
item.orientation === specificOrientation;
const objectNotOrientationPredicate = (item) =>
item.orientation !== specificOrientation;
const enforcedOrientation = "top";
const objectEnforcedOrientationPredicate = (item) =>
item.matches[enforcedOrientation];
const objectMethodPredicate = (item) => item.isActive();
const objectMethodWithArgPredicate = (item) => item.isSpecificType("special");
Ready to run.
Test | Ops/sec | |
---|---|---|
_.filter |
| ready |
.filter |
| ready |
You can edit these tests or add more tests to this page by appending /edit to the URL.