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
var source = new Uint8Array([0x32, 0x65, 0x42, 0x56]);
var nativeEndian = new Uint16Array(new Uint8Array([0x12, 0x34]).buffer)[0] === 0x3412;
var buf = new ArrayBuffer(1600);
function peek(bytes, littleEndian) {
var i, _i, _j;
if (littleEndian == null) {
littleEndian = false;
}
if (littleEndian === nativeEndian) {
for (i = _i = 0; _i < bytes; i = _i += 1) {
uint8[i] = source[i];
}
} else {
for (i = _j = 0; _j < bytes; i = _j += 1) {
uint8[bytes - i - 1] = source[i];
}
}
}
var buf2 = new ArrayBuffer(10);
var uint8_2 = new Uint8Array(buf2);
function peek2(bytes) {
for (var i = 0; i < bytes; i++) {
uint8_2[i] = source[i];
}
}
function readUInt32_1(position, littleEndian) {
// peek(4, littleEndian);
return uint32[position/4];
}
function readUInt32_2(position, littleEndian) {
// peek2(4);
return view.getUint32(position, littleEndian);
}
function readUInt32_3(position, littleEndian) {
var a0 = source[position],
a1 = source[position + 1],
a2 = source[position + 2],
a3 = source[position + 3];
if (littleEndian)
return ((a3 << 24) >>> 0) + (a2 << 16) + (a1 << 8) + (a0);
else
return ((a0 << 24) >>> 0) + (a1 << 16) + (a2 << 8) + (a3);
}
Ready to run.
Test | Ops/sec | |
---|---|---|
Typed Arrays |
| ready |
DataView |
| ready |
manual |
| ready |
You can edit these tests or add more tests to this page by appending /edit to the URL.