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>
function CustomView(buffer) {
this.buffer = buffer;
this.u8 = new Uint8Array(buffer);
this.u32 = new Uint32Array(buffer);
}
CustomView.prototype.getUint32 = function (index) {
return this.u32[(index/4)|0];
}
CustomView.prototype.setUint32 = function (index, value) {
this.u32[(index/4)|0] = value;
}
CustomView.prototype.getUint32_2 = function (i) {
return (this.u8[i+3] << 24) | (this.u8[i+2] << 16) | (this.u8[i+1] << 8) | this.u8[i];
}
CustomView.prototype.setUint32_2 = function (index, value) {
this.u8[index] = (value) & 0xff;
this.u8[index+1] = (value >> 8) & 0xff;
this.u8[index+2] = (value >> 16) & 0xff;
this.u8[index+3] = (value >> 24) &0xff;
}
var len = 1024;
var len2 = len/4;
var a = new ArrayBuffer(len);
var u32 = new Uint32Array(a);
var dv = new DataView(a);
var cv = new CustomView(a);
</script>
Ready to run.
Test | Ops/sec | |
---|---|---|
DataView write |
| ready |
Uint8 write |
| ready |
DataView read |
| ready |
Uint8 read |
| ready |
CustomView write |
| ready |
CustomView read |
| ready |
CustomView write2 |
| ready |
CustomView read2 |
| ready |
You can edit these tests or add more tests to this page by appending /edit to the URL.