Toggle navigation
MeasureThat.net
Create a benchmark
Tools
Feedback
FAQ
Register
Log In
Run results for:
TextDecoder vs Js
Go to the benchmark
Embed
Embed Benchmark Result
Run details:
User agent:
Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/130.0.0.0 Safari/537.36
Browser:
Chrome 130
Operating system:
Mac OS X 10.15.7
Device Platform:
Desktop
Date tested:
one year ago
Test name
Executions per second
decodeNative
6267210.0 Ops/sec
decodeCharCode
4847934.5 Ops/sec
decoderJs
3489333.2 Ops/sec
Script Preparation code:
var arr = new Uint8Array([97, 98, 99, 100, 102, 103, 97, 98, 99, 100, 102, 103, 97, 98, 99, 100, 102, 103, 97, 98, 99, 100, 102, 103, 97, 98, 99, 100, 102, 103, 97, 98, 99, 100, 102, 103, 97, 98, 99, 100, 102, 103, 97, 98, 99, 100, 102, 103, 97, 98, 99, 100, 102, 103, 97, 98, 99]) var decoder = new TextDecoder(); function decodeNative(arr) { return decoder.decode(arr); } function decodeCharCode(arr) { return String.fromCharCode.apply(null, arr); } function decoderJs(buffer) { var start = 0; var end = buffer.byteLength; if (end - start < 1) { return ""; } var str = ""; for (var i = start; i < end;) { var t = buffer[i++]; if (t <= 0x7F) { str += String.fromCharCode(t); } else if (t >= 0xC0 && t < 0xE0) { str += String.fromCharCode((t & 0x1F) << 6 | buffer[i++] & 0x3F); } else if (t >= 0xE0 && t < 0xF0) { str += String.fromCharCode((t & 0xF) << 12 | (buffer[i++] & 0x3F) << 6 | buffer[i++] & 0x3F); } else if (t >= 0xF0) { var t2 = ((t & 7) << 18 | (buffer[i++] & 0x3F) << 12 | (buffer[i++] & 0x3F) << 6 | buffer[i++] & 0x3F) - 0x10000; str += String.fromCharCode(0xD800 + (t2 >> 10)); str += String.fromCharCode(0xDC00 + (t2 & 0x3FF)); } } return str; }
Tests:
decodeNative
decodeNative(arr)
decodeCharCode
decodeCharCode(arr)
decoderJs
decoderJs(arr)