HTML Preparation code:
AخA
 
1
<!--your preparation HTML code goes here-->
Script Preparation code:
x
 
function bigIntToBigEndianBytesLoop(value) {
    const hex = value.toString(16).padStart(8 * 2, '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 bigIntToBigEndianBytesDataView(value) {
    const buf = new ArrayBuffer(8);
    const view = new DataView(buf);
    view.setBigUint64(0, value);
    return new Uint8Array(buf);
}
Tests:
  • for-loop

     
    bigIntToBigEndianBytesLoop(2382975329865n);
  • dataview

     
    bigIntToBigEndianBytesDataView(2382975329865n);
Rendered benchmark preparation results:

Suite status: <idle, ready to run>

Previous results

Experimental features:

  • Test case name Result
    for-loop
    dataview

    Fastest: N/A

    Slowest: N/A

Latest run results:
Run details: (Test run date: 5 months ago)
Mozilla/5.0 (Linux; Android 10; K) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/126.0.0.0 Mobile Safari/537.36
Chrome Mobile 126 on Android
View result in a separate tab
Test name Executions per second
for-loop 2036562.4 Ops/sec
dataview 1237397.4 Ops/sec