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
Testing if naive parseInt is faster than other things that come to mind.
var bits = [0, 0, 1, 1, 0, 0, 1, 0];
var makeByteR = (b) => b.reduceRight((c, bi, i) => (bi ? c | (1 << 7-i) : c), 0);
var makeByteF = (b, c = 0, i) => {
for(i = 0; i<8; i++){
if(b[7-i]){
c |= 1 << i ;
}
}
return c;
}
var makeByteP = (b, c = 0) => {
while(b.length)c = b.pop() ? c | 1 << 7 - b.length: c;
return c;
}
Ready to run.
Test | Ops/sec | |
---|---|---|
Join + parseInt |
| ready |
reduce |
| ready |
for loop |
| ready |
while+pop |
| ready |
You can edit these tests or add more tests to this page by appending /edit to the URL.