Toggle navigation
MeasureThat.net
Create a benchmark
Tools
Feedback
FAQ
Register
Log In
Run results for:
array buffer to hex conversion 3 methods
convert array buffer to hex
Go to the benchmark
Embed
Embed Benchmark Result
Run details:
User agent:
Mozilla/5.0 (X11; Linux x86_64; rv:146.0) Gecko/20100101 Firefox/146.0
Browser:
Firefox 146
Operating system:
Linux
Device Platform:
Desktop
Date tested:
3 months ago
Test name
Executions per second
directly set
2439992.5 Ops/sec
push values
4291398.0 Ops/sec
buf2hex()
1953179.2 Ops/sec
Script Preparation code:
var saltVal = crypto.getRandomValues(new Uint8Array(16)); function arrayBufferToHexString(bytes) { bytes = new Uint8Array(bytes); var hex = new Array(bytes.length); for (let i = 0; i < bytes.length; i++) { hex[i] = ("0" + bytes[i].toString(16)).slice(-2); } return hex.join(""); } function bytesToHexString(bytes) { bytes = new Uint8Array(bytes); var hexBytes = []; for (var i = 0; i < bytes.length; i++) { var byteString = bytes[i].toString(16); if (byteString.length < 2) byteString = "0" + byteString; hexBytes.push(byteString); } return hexBytes.join(""); } function buf2hex(buffer) { // buffer is an ArrayBuffer return [...new Uint8Array(buffer)] .map(x => x.toString(16).padStart(2, '0')) .join(''); }
Tests:
directly set
arrayBufferToHexString(saltVal);
push values
bytesToHexString(saltVal)
buf2hex()
buf2hex(saltVal)