Toggle navigation
MeasureThat.net
Create a benchmark
Tools
Feedback
FAQ
Register
Log In
Run results for:
Uint8Array to String
Benchmark of various methods used to convert a Uint8Array to a string value
Go to the benchmark
Embed
Embed Benchmark Result
Run details:
User agent:
Mozilla/5.0 (iPhone; CPU iPhone OS 18_3_2 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/18.3.1 Mobile/15E148 Safari/604.1
Browser:
Mobile Safari 18
Operating system:
iOS 18.3.2
Device Platform:
Mobile
Date tested:
one year ago
Test name
Executions per second
strapply_arrpush
2141.8 Ops/sec
strapply_arrconcat
2132.8 Ops/sec
strapply_strconcat
2086.2 Ops/sec
strspread_arrpush
724.0 Ops/sec
strspread_arrconcat
718.7 Ops/sec
strspread_strconcat
711.8 Ops/sec
Script Preparation code:
uint8Array = Uint8Array.from([...Array(2 ** 16)].map(() => Math.floor(Math.random() * (2 ** 8)))); CHUNK_SZ = 0x8000; function strapply_arrpush(uint8Array) { const c = []; for (let i = 0; i < uint8Array.length; i += CHUNK_SZ) { c.push( String.fromCharCode.apply(null, uint8Array.subarray(i, i + CHUNK_SZ)) ); } return c.join(""); } function strapply_arrconcat(uint8Array) { let c = []; for (let i = 0; i < uint8Array.length; i += CHUNK_SZ) { c = c.concat( String.fromCharCode.apply(null, uint8Array.subarray(i, i + CHUNK_SZ)) ); } return c; } function strapply_strconcat(uint8Array) { let s = ""; for (let i = 0; i < uint8Array.length; i += CHUNK_SZ) { s += ( String.fromCharCode.apply(null, uint8Array.subarray(i, i + CHUNK_SZ)) ); } return s; } function strspread_arrpush(uint8Array) { const c = []; for (let i = 0; i < uint8Array.length; i += CHUNK_SZ) { c.push( String.fromCharCode(...uint8Array.subarray(i, i + CHUNK_SZ)) ); } return c.join(""); } function strspread_arrconcat(uint8Array) { let c = []; for (let i = 0; i < uint8Array.length; i += CHUNK_SZ) { c = c.concat( String.fromCharCode(...uint8Array.subarray(i, i + CHUNK_SZ)) ); } return c; } function strspread_strconcat(uint8Array) { let s = ""; for (let i = 0; i < uint8Array.length; i += CHUNK_SZ) { s += ( String.fromCharCode(...uint8Array.subarray(i, i + CHUNK_SZ)) ); } return s; }
Tests:
strapply_arrpush
strapply_arrpush(uint8Array)
strapply_arrconcat
strapply_arrconcat(uint8Array)
strapply_strconcat
strapply_strconcat(uint8Array)
strspread_arrpush
strspread_arrpush(uint8Array)
strspread_arrconcat
strspread_arrconcat(uint8Array)
strspread_strconcat
strspread_strconcat(uint8Array)