Toggle navigation
MeasureThat.net
Create a benchmark
Tools
Feedback
FAQ
Register
Log In
Run results for:
BigInt to BigEndian Bytes
Go to the benchmark
Embed
Embed Benchmark Result
Run details:
User agent:
Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:133.0) Gecko/20100101 Firefox/133.0
Browser:
Firefox 133
Operating system:
Windows
Device Platform:
Desktop
Date tested:
one year ago
Test name
Executions per second
Loop ParseInt
1628691.1 Ops/sec
Loop Constructor
881863.2 Ops/sec
DataView
1584876.9 Ops/sec
Direct
3606171.5 Ops/sec
HTML Preparation code:
<!--your preparation HTML code goes here-->
Script Preparation code:
function bigIntToBigEndianBytesLoopParseInt(value) { const hex = value.toString(16).padStart(16, '0'); const bytes = new Uint8Array(8); for (let i = 0; i < 8; i++) { bytes[i] = parseInt(hex.slice(i * 2, i * 2 + 2), 16); } return bytes; } function bigIntToBigEndianBytesLoopConstructor(value) { const hex = value.toString(16).padStart(16, '0'); const bytes = new Uint8Array(8); for (let i = 0; i < 8; i++) { bytes[i] = Number(hex.slice(i * 2, i * 2 + 2), 16); } return bytes; } function bigIntToBigEndianBytesDataView(value) { const buf = new ArrayBuffer(8); const view = new DataView(buf); view.setBigUint64(0, value); return new Uint8Array(buf); } function bigIntToUint8ArrayDirectConstructor(value) { const result = new Uint8Array(8); result[7] = Number(value & 0xffn); result[6] = Number((value >> 8n) & 0xffn); result[5] = Number((value >> 16n) & 0xffn); result[4] = Number((value >> 24n) & 0xffn ); result[3] = Number((value >> 32n) & 0xffn); result[2] = Number((value >> 40n) & 0xffn); result[1] = Number((value >> 48n) & 0xffn); result[0] = Number((value >> 56n) & 0xffn); return result; } function bigIntToUint8ArrayDirectParseInt(value) { const result = new Uint8Array(8); result[7] = parseInt(value & 0xffn); result[6] = parseInt((value >> 8n) & 0xffn); result[5] = parseInt((value >> 16n) & 0xffn); result[4] = parseInt((value >> 24n) & 0xffn ); result[3] = parseInt((value >> 32n) & 0xffn); result[2] = parseInt((value >> 40n) & 0xffn); result[1] = parseInt((value >> 48n) & 0xffn); result[0] = parseInt((value >> 56n) & 0xffn); return result; }
Tests:
Loop ParseInt
bigIntToBigEndianBytesLoopParseInt(32149814014n)
Loop Constructor
bigIntToBigEndianBytesLoopConstructor(32149814014n)
DataView
bigIntToBigEndianBytesDataView(32149814014n)
Direct Constructor
bigIntToUint8ArrayDirectConstructor(32149814014n)
Direct ParseInt
bigIntToUint8ArrayDirectParseInt(32149814014n)