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));
}
function numberToUint8Array64LE_withLoop(num) {
const result = new Uint8Array(8)
for (let i = 0; i < 8; i++) {
result[i] = num & 0xff
num = num >>> 8
}
return result
}
function numberToUint8Array64LE_withLoop_noAssignment(num) {
const result = new Uint8Array(8)
result[0] = num & 0xff
for (let i = 1, j = 8; i < 8; i++, j += 8) {
result[i] = (num >>> j) & 0xff
}
return result
}
function numberToUint8Array64LE_withLoop_noAssignment_noSecondCounter(num) {
const result = new Uint8Array(8)
result[0] = num & 0xff
for (let i = 1; i < 8; i++) {
result[i] = (num >>> (i << 3)) & 0xff
}
return result
}
function numberToUint8Array64LE_withLoop_bugoutOn0(num) {
const result = new Uint8Array(8)
for (let i = 0; num != 0; i++, num = num >>> 8) {
result[i] = num & 0xff
}
return result
}
numberToUint8Array64LE_DataView(0xababababab)
numberToUint8Array64LE_direct(0xababababab)
numberToUint8Array64LE_bigint(0xababababab)
numberToUint8Array64LE_withLoop(0xababababab)
numberToUint8Array64LE_withLoop_noAssignment(0xababababab)
numberToUint8Array64LE_withLoop_noAssignment_noSecondCounter(0xababababab)
numberToUint8Array64LE_withLoop_bugoutOn0(0xababababab)
numberToUint8Array64LE_withLoop_bugoutOn0(0xab)
numberToUint8Array64LE_withLoop_bugoutOn0(0)
--enable-precise-memory-info
flag.
Test case name | Result |
---|---|
Through DataView | |
Direct | |
With BigInt | |
Simple Loop | |
Loop No Assignment | |
Loop No Assignment No Second Counter | |
Loop Exit on 0 | |
Loop Exit on 0 single byte | |
Loop Exit on 0 with 0 |
Test name | Executions per second |
---|---|
Through DataView | 2155225.8 Ops/sec |
Direct | 7982840.5 Ops/sec |
With BigInt | 982669.6 Ops/sec |
Simple Loop | 7913821.5 Ops/sec |
Loop No Assignment | 7869215.5 Ops/sec |
Loop No Assignment No Second Counter | 7947380.5 Ops/sec |
Loop Exit on 0 | 8076627.5 Ops/sec |
Loop Exit on 0 single byte | 8140286.5 Ops/sec |
Loop Exit on 0 with 0 | 8233824.5 Ops/sec |
It seems you're providing a JSON array of data, likely from a web browser's profiling or benchmarking results. I'll assume that this data represents the performance of different tests on various browsers and environments.
After analyzing the provided data, I'll answer your questions:
If you have specific questions about a particular test or would like me to analyze the data further, feel free to ask!