Toggle navigation
MeasureThat.net
Create a benchmark
Tools
Feedback
FAQ
Register
Log In
Run results for:
TextDecoder
Go to the benchmark
Embed
Embed Benchmark Result
Run details:
User agent:
Mozilla/5.0 (Linux; Android 10; K) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/138.0.0.0 Mobile Safari/537.36
Browser:
Chrome Mobile 138
Operating system:
Android
Device Platform:
Mobile
Date tested:
9 months ago
Test name
Executions per second
TextDecoder
3136647.2 Ops/sec
Concat
5828569.5 Ops/sec
Script Preparation code:
var ToStringFromUTF16_1 = (function() { var UTF16 = new TextDecoder("utf-16"); return function(bytes, startIndex, length) { startIndex = startIndex | 0; if (typeof length !== "undefined") length += startIndex; return UTF16.decode(bytes.subarray(startIndex, length)); }; })(); var ToStringFromUTF16_2 = (function() { var fromCharCode = String.fromCharCode; return function (bytes, startIndex, length) { startIndex = startIndex | 0; if (typeof length === "undefined") length = bytes.length - startIndex; var s = "", endIndex = startIndex + length, i = startIndex; while (i < endIndex) { var octet = bytes[i], bytesNeeded = 0, codePoint = 0; if (octet <= 0x7F) { bytesNeeded = 0; codePoint = octet & 0xFF; } else if (octet <= 0xDF) { bytesNeeded = 1; codePoint = octet & 0x1F; } else if (octet <= 0xEF) { bytesNeeded = 2; codePoint = octet & 0x0F; } else if (octet <= 0xF4) { bytesNeeded = 3; codePoint = octet & 0x07; } if (endIndex - i - bytesNeeded > 0) { for (var j = 0; j < bytesNeeded; j++) { octet = bytes[i + j + 1]; codePoint = (codePoint << 6) | (octet & 0x3F); } } else { codePoint = 0xFFFD; // REPLACEMENT CHARACTER bytesNeeded = endIndex - i; } //s += String.fromCodePoint(codePoint); //if (!(codePoint < 0x10FFFF && (codePoint>>>0) === codePoint)) // throw RangeError("Invalid code point: " + codePoint); if (codePoint <= 0xFFFF) { // BMP code point s += fromCharCode(codePoint); } else { codePoint -= 0x10000; s += fromCharCode((codePoint >> 10) + 0xD800, // high surrogate (codePoint % 0x400) + 0xDC00); // low surrogate } i += bytesNeeded + 1; } return s; }; })(); var bytes = new Uint8Array([32, 0, 32, 0, 32, 0, 32, 0, 32, 0, 32, 0, 32, 0, 32, 0, 32, 0, 32, 0])
Tests:
TextDecoder
ToStringFromUTF16_1(bytes);
Concat
ToStringFromUTF16_2(bytes);