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
10_000 rows of 0-9_999
map x => x
as straightforward as it gets to measure as close to clock cycles as we can
<script src="https://cdn.jsdelivr.net/npm/lodash@4.17.21/lodash.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/ramda/0.29.1/ramda.min.js" integrity="sha512-PVSAmDFNqey8GMII8s9rjjkCFvUgzfsfi8FCRxQa3TkPZfdjCIUM+6eAcHIFrLfW5CTFAwAYS4pzl7FFC/KE7Q==" crossorigin="anonymous" referrerpolicy="no-referrer"></script>
const arr = Array(10_000)
.fill(undefined)
.map((_, i) => i);
// copy of ramda internal
function _ramdaMap(fn, functor) {
var idx = 0;
var len = functor.length;
var result = Array(len);
while (idx < len) {
result[idx] = fn(functor[idx]);
idx += 1;
}
return result;
}
// put forOf and for in functions for consistency
function forOfPush(a) {
const nextArr = [];
for (const v of a) {
nextArr.push(v);
}
return nextArr;
}
function forISet(a) {
const nextArr = Array(a.length);
for (let i = 0; i < a.length; i++) {
nextArr[i] = a[i];
}
return nextArr;
}
Ready to run.
Test | Ops/sec | |
---|---|---|
lodash map |
| ready |
ramda map |
| ready |
array#map |
| ready |
ramda map curried |
| ready |
ramda _map |
| ready |
for..of |
| ready |
for w/ preset array length |
| ready |
You can edit these tests or add more tests to this page by appending /edit to the URL.