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 (iPhone; CPU iPhone OS 18_3_2 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) CriOS/134.0.6998.99 Mobile/15E148 Safari/604.1
Browser:
Chrome Mobile iOS 134
Operating system:
iOS 18.3.2
Device Platform:
Mobile
Date tested:
one year ago
Test name
Executions per second
decodeNative
4998054.5 Ops/sec
decodeCharCode
2663638.8 Ops/sec
decoderJs
4699381.0 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)