// Row 148 round 3: a no-module control for the probe. Same input size as a probe cell, no parser: // line split, one regex replace per line, character concatenation. Prints " KiB ms". // If this fails a ratio rule, the rule is measuring the machine, not the module. // Usage: node ctl-concat.mjs const k = Number(process.argv[2]); const n = k * 1024; const line = '-' + 'abcdefghij'.repeat(Math.ceil(n / 10)).slice(0, n - 1); const t = []; for (let r = 0; r < 5; r++) { const t0 = performance.now(); const lines = line.replace(/\r\n?/g, '\n').split('\n').map(l => l.replace(/^[ \t]+/, w => w)); let p = ''; const s = lines[0]; for (let i = 0; i < s.length; i++) p += s[i]; p.length; t.push(performance.now() - t0); } t.sort((a, b) => a - b); console.log(k, 'KiB', t[2].toFixed(1), 'ms');