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://esm.sh/@faker-js/faker"/>
function formatNumberAsFileSize1 (value) {
const units = ['bytes', 'Kb', 'Mb', 'Gb']
if (!value) return '-'
let iterations = 0
while (value >= 1024 && iterations < units.length - 1) {
value = value / 1024
iterations++
}
return value
}
function formatNumberAsFileSize2 (value) {
if (!value) return '-'
const units = ['bytes', 'Kb', 'Mb', 'Gb']
const exponent = Math.min(Math.floor(Math.log2(value) / 10), units.length - 1)
const size = value / Math.pow(1024, exponent)
return size
}
var data = [...Array(1000).map(() => faker.number.int(Math.pow(1024, Math.random() * 4))]Ready to run.
| Test | Ops/sec | |
|---|---|---|
| fn 1 | | ready |
| fn 2 | | ready |
You can edit these tests or add more tests to this page by appending /edit to the URL.