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:
7 months ago
TextDecoder, subarray
428K/s
TextDecoder, new uint8array
256K/s
String.fromCharCode, subarray
14K/s
View exact numbers
Test name
Executions per second
✓
TextDecoder, subarray
428,186 Ops/sec
TextDecoder, new uint8array
255,830 Ops/sec
String.fromCharCode, subarray
13,931 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))