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 arraySize = 100;
// 1. Array for truthiness check (approximates `_.any(arrOfValues)`)
const mixedTruthinessArray = [];
for (let i = 0; i < arraySize; i++) {
if (i === Math.floor(arraySize / 2)) {
// Ensure one truthy value
mixedTruthinessArray.push(true);
} else if (i === Math.floor(arraySize / 1.5)) {
// Ensure one truthy string value
mixedTruthinessArray.push("hello");
} else {
mixedTruthinessArray.push(i % 5 === 0 ? 0 : false); // Mix of falsy values
}
}
const truthyPredicate = (value) => !!value;
// 2. Array of objects for predicate testing
const arrayOfObjects = [];
for (let i = 0; i < arraySize; i++) {
arrayOfObjects.push({
id: i,
type: i % 10 === 0 ? "special" : "normal",
value: Math.random() * 100,
isHidden: i % 7 === 0,
stringValue: (i * 1.5).toFixed(2),
});
}
// Simulates `!getIsHidden(item)`
const isVisiblePredicate = (item) => !item.isHidden;
// Simulates `s.type === 'R^2' && s.value !== undefined && s.value < 0`
const complexPropertyPredicate = (item) =>
item.type === "special" && item.value < 10 && item.id > 5;
// Simulates `parseFloat(v) <= 0`
const stringParsePredicate = (item) => parseFloat(item.stringValue) < 50;
const allHiddenItems = Array(arraySize)
.fill(null)
.map((_, i) => ({ id: i, isHidden: true }));
Ready to run.
Test | Ops/sec | |
---|---|---|
_.any |
| ready |
.some |
| ready |
You can edit these tests or add more tests to this page by appending /edit to the URL.