Toggle navigation
MeasureThat
.net
Create a benchmark
Tools
Feedback
FAQ
Register
Log In
Run results for:
BigInt to BigEndian Bytes (extended by trincot, v3)
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 Edg/131.0.0.0
Browser:
Chrome 131
Operating system:
Windows
Device Platform:
Desktop
Date tested:
one year ago
With split
11.8M/s
With split and forward assignment
11.6M/s
Direct Constructor
6.6M/s
View exact numbers
Test name
Executions per second
✓
With split
11,788,106 Ops/sec
With split and forward assignment
11,554,508 Ops/sec
Direct Constructor
6,574,462 Ops/sec
HTML Preparation code:
<!--your preparation HTML code goes here-->
Script Preparation code:
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; } // Added by trincot: first split BigInt into two numbers (32 bit), then work with those only function bigIntToUint8ArrayDirectConstructor2(value) { const result = new Uint8Array(8); const low = Number(value & 0xffffffffn); const high = Number(value >> 32n); result[7] = low & 0xff; result[6] = (low >>> 8) & 0xff; result[5] = (low >>> 16) & 0xff; result[4] = low >>> 24; result[3] = high & 0xff; result[2] = (high >>> 8) & 0xff; result[1] = (high >>> 16) & 0xff; result[0] = high >>> 24; return result; } // Forward assignment instead of backward function bigIntToUint8ArrayDirectConstructor3(value) { const result = new Uint8Array(8); const low = Number(value & 0xffffffffn); const high = Number(value >> 32n); result[0] = high >>> 24; result[1] = (high >>> 16) & 0xff; result[2] = (high >>> 8) & 0xff; result[3] = high & 0xff; result[4] = low >>> 24; result[5] = (low >>> 16) & 0xff; result[6] = (low >>> 8) & 0xff; result[7] = low & 0xff; return result; }
Tests:
Direct Constructor
bigIntToUint8ArrayDirectConstructor(32149814014n)
With split
bigIntToUint8ArrayDirectConstructor2(32149814014n)
With split and forward assignment
bigIntToUint8ArrayDirectConstructor3(32149814014n)