Toggle navigation
MeasureThat.net
Create a benchmark
Tools
Feedback
FAQ
Register
Log In
Run results for:
TextDecoder compared to String.fromCharCode
Go to the benchmark
Embed
Embed Benchmark Result
Run details:
User agent:
Mozilla/5.0 (X11; Linux x86_64; rv:145.0) Gecko/20100101 Firefox/145.0
Browser:
Firefox 145
Operating system:
Linux
Device Platform:
Desktop
Date tested:
4 months ago
Test name
Executions per second
String.fromCharCode, subarray
13930.8 Ops/sec
TextDecoder, new uint8array
255830.1 Ops/sec
TextDecoder, subarray
428186.2 Ops/sec
Script Preparation code:
const testLength = 1000; const startSlice = 300; const endSlice = 700; const getRandomCharCode = () => Math.floor(Math.random() * 26) + 97; // a-z letters const bytes = Array.from({length: testLength}, () => getRandomCharCode()); var buffer = new Uint8Array(bytes); var decoder = new TextDecoder(); // default 'utf-8' or 'utf8'
Tests:
String.fromCharCode, subarray
String.fromCharCode(...buffer.subarray(startSlice, endSlice));
TextDecoder, new uint8array
const slice = new Uint8Array(buffer.buffer, startSlice, endSlice - startSlice); decoder.decode(slice);
TextDecoder, subarray
decoder.decode(buffer.subarray(startSlice, endSlice))