{"ScriptPreparationCode":"let s1MB = \u00220123456789\u0022.repeat(1000*100);\r\nvar strings1MB = Array.from(Array(20)).map(o=\u003Es1MB \u002B String.fromCharCode(32\u002B~~(Math.random()*96)))\r\n\r\nlet s2MB = \u00220123456789\u0022.repeat(1000*200);\r\nvar strings2MB = Array.from(Array(20)).map(o=\u003Es2MB \u002B String.fromCharCode(32\u002B~~(Math.random()*96)))\r\n\r\nlet s10MB = \u00220123456789\u0022.repeat(1000*1000);\r\nvar strings10MB = Array.from(Array(20)).map(o=\u003Es10MB \u002B String.fromCharCode(32\u002B~~(Math.random()*96)))\r\nfunction compare(a, b) {\r\n const lenA = a.length;\r\n const lenB = b.length;\r\n const minLen = lenA \u003C lenB ? lenA : lenB;\r\n var i = 0;\r\n for (; i \u003C minLen; \u002B\u002Bi) {\r\n const ca = a.charCodeAt(i);\r\n const cb = b.charCodeAt(i);\r\n if (ca \u003E cb)\r\n return 1;\r\n else if (ca \u003C cb)\r\n return -1;\r\n }\r\n if (lenA === lenB)\r\n return 0;\r\n return lenA \u003E lenB ? 1 : -1;\r\n};","TestCases":[{"Name":"1MB string comparison","Code":"const s1 = strings1MB[~~(strings1MB.length*Math.random())];\r\nconst s2 = strings1MB[~~(strings1MB.length*Math.random())];\r\nconst b = s1 === s2;","IsDeferred":false},{"Name":"2MB string comparison","Code":"const s1 = strings2MB[~~(strings2MB.length*Math.random())];\r\nconst s2 = strings2MB[~~(strings2MB.length*Math.random())];\r\nconst b = s1 === s2;","IsDeferred":false},{"Name":"10MB string comparison","Code":"const s1 = strings10MB[~~(strings10MB.length*Math.random())];\r\nconst s2 = strings10MB[~~(strings10MB.length*Math.random())];\r\nconst b = s1 === s2;","IsDeferred":false},{"Name":"1MB string comparison\u002B","Code":"const s1 = strings1MB[~~(strings1MB.length*Math.random())];\r\nconst s2 = strings1MB[~~(strings1MB.length*Math.random())];\r\nconst b = compare(s1,s2);","IsDeferred":false},{"Name":"2MB string comparison\u002B","Code":"const s1 = strings2MB[~~(strings2MB.length*Math.random())];\r\nconst s2 = strings2MB[~~(strings2MB.length*Math.random())];\r\nconst b = compare(s1,s2);","IsDeferred":false},{"Name":"10MB string comparison\u002B","Code":"const s1 = strings10MB[~~(strings10MB.length*Math.random())];\r\nconst s2 = strings10MB[~~(strings10MB.length*Math.random())];\r\nconst b = compare(s1,s2);","IsDeferred":false}]}