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 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/131.0.0.0 Safari/537.36
Browser:
Chrome 131
Operating system:
Windows
Device Platform:
Desktop
Date tested:
one year ago
Test name
Executions per second
directly set
2392962.5 Ops/sec
push values
3319517.2 Ops/sec
buf2hex()
1645414.4 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)