Toggle navigation
MeasureThat.net
Create a benchmark
Tools
Feedback
FAQ
Register
Log In
Run results for:
JS number to UInt8Array 64-bit little endian
Go to the benchmark
Embed
Embed Benchmark Result
Run details:
User agent:
Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/131.0.0.0 Safari/537.36
Browser:
Chrome 131
Operating system:
Windows
Device Platform:
Desktop
Date tested:
one year ago
Test name
Executions per second
Through DataView
3603310.8 Ops/sec
Direct
51751052.0 Ops/sec
With BigInt
1359617.8 Ops/sec
Script Preparation code:
function numberToUint8Array64LE_DataView(num) { const buf = new ArrayBuffer(8) const view = new DataView(buf) view.setUint32(0, num, true) view.setUint32(4, num >>> 32, true) return new Uint8Array(buf) } function numberToUint8Array64LE_direct(num) { const result = new Uint8Array(8) result[0] = num & 0xff result[1] = (num >>> 8) & 0xff result[2] = (num >>> 16) & 0xff result[3] = (num >>> 24) & 0xff result[4] = (num >>> 32) & 0xff result[5] = (num >>> 40) & 0xff result[6] = (num >>> 48) & 0xff result[7] = (num >>> 56) & 0xff return result } function numberToUint8Array64LE_bigint(num) { const bigIntValue = BigInt.asUintN(64, BigInt(num)); const buffer = new ArrayBuffer(8); const dataView = new DataView(buffer); dataView.setBigUint64(0, bigIntValue, true); return Uint8Array.from(buffer.slice(0, 8)); }
Tests:
Through DataView
numberToUint8Array64LE_DataView(0xababababab)
Direct
numberToUint8Array64LE_direct(0xababababab)
With BigInt
numberToUint8Array64LE_bigint(0xababababab)