{"ScriptPreparationCode":null,"TestCases":[{"Name":"Raw repeat","Code":"function repeat(target, times) {\r\n var strLen = target.length * times;\r\n var buf = new ArrayBuffer(strLen * 2); \r\n var bufView = new Uint16Array(buf);\r\n var charCodes = target.split(\u0027\u0027).map(char =\u003E char.charCodeAt(0));\r\n var charCodesLen = charCodes.length;\r\n for (var i = 0; i \u003C strLen; i\u002B\u002B) {\r\n \tbufView[i] = charCodes[i % charCodesLen];\r\n }\r\n \r\n return String.fromCharCode.apply(null, bufView);\r\n}\r\n\r\nrepeat(\u0027asdf\u0027, 30000);\r\n\r\n","IsDeferred":false},{"Name":"Smart repeat","Code":"function decimalNumberToReversedBinaryString(dec) {\r\n return Number(dec).toString(2).split(\u0027\u0027).reverse().join(\u0027\u0027);\r\n}\r\n \r\nfunction smartRepeat(target, times) {\r\n let ret = \u0022\u0022;\r\n let seed = target;\r\n \r\n // Take a number and turn it into binary. Reverse it so we can iterate small to large\r\n // 13 =\u003E 1101 in binary =\u003E 1011 reversed so the 1s place is at the front\r\n let binaryTimes = decimalNumberToReversedBinaryString(times);\r\n for (let i = 0; i \u003C binaryTimes.length; i\u002B\u002B) {\r\n if (parseInt(binaryTimes[i])) { // if bit is set, add the current seed to the total\r\n ret \u002B= seed;\r\n }\r\n seed \u002B= seed; // double the seed for the next iteration\r\n }\r\n return ret;\r\n}\r\n\r\nsmartRepeat(\u0027asdf\u0027, 30000);","IsDeferred":false}]}