Script Preparation code:
x
 
var hexVal = 'ed0c356af33bb022afe7c5f8557ad89c';
function hexToArrayBuffer(hex) {
    return new Uint8Array(hex.match(/[\da-f]{2}/gi).map((h) => {
        return parseInt(h, 16);
    })).buffer;
}
function hexStringToUint8Array(hexString) {
    var arrayBuffer = new Uint8Array(hexString.length / 2);
    for (var i = 0; i < hexString.length; i += 2) {
        var byteValue = parseInt(hexString.substr(i, 2), 16);
        arrayBuffer[i / 2] = byteValue;
    }
    return arrayBuffer;
}
Tests:
  • regex match

     
    hexToArrayBuffer(hexVal)
  • parseInt 16

     
    hexStringToUint8Array(hexVal)
Rendered benchmark preparation results:

Suite status: <idle, ready to run>

Previous results

Experimental features:

  • Test case name Result
    regex match
    parseInt 16

    Fastest: N/A

    Slowest: N/A

Latest run results:
Run details: (Test run date: one month ago)
Mozilla/5.0 (Linux; Android 10; K) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/134.0.0.0 Mobile Safari/537.36
Chrome Mobile 134 on Android
View result in a separate tab
Test name Executions per second
regex match 232294.2 Ops/sec
parseInt 16 757726.8 Ops/sec