(tool, action, phase, count, fn)
| 845 | } |
| 846 | |
| 847 | async function sample(tool, action, phase, count, fn) { |
| 848 | for (let index = 0; index < count; index += 1) { |
| 849 | const started = performance.now(); |
| 850 | let result; |
| 851 | try { |
| 852 | result = await fn(tool, index); |
| 853 | } catch (error) { |
| 854 | result = { |
| 855 | ok: false, |
| 856 | status: null, |
| 857 | stdout: "", |
| 858 | stderr: error?.stack || String(error), |
| 859 | durationMs: performance.now() - started, |
| 860 | }; |
| 861 | } |
| 862 | rows.push({ |
| 863 | tool, |
| 864 | action, |
| 865 | phase, |
| 866 | iteration: index + 1, |
| 867 | durationMs: roundMs(result.durationMs ?? performance.now() - started), |
| 868 | status: result.ok ? "ok" : "failed", |
| 869 | exitCode: result.status ?? null, |
| 870 | stdoutBytes: Buffer.byteLength(result.stdout || ""), |
| 871 | stderrBytes: Buffer.byteLength(result.stderr || ""), |
| 872 | note: result.note || conciseFailure(result), |
| 873 | }); |
| 874 | const sampleLabel = |
| 875 | count === 1 ? "" : ` ${String(index + 1).padStart(2, "0")}/${count}`; |
| 876 | console.log( |
| 877 | `${tool.padEnd(13)} ${phase.padEnd(4)} ${action.padEnd(28)}${sampleLabel} ${formatMs( |
| 878 | result.durationMs, |
| 879 | ).padStart(9)} ${result.ok ? "ok" : "failed"}`, |
| 880 | ); |
| 881 | } |
| 882 | } |
| 883 | |
| 884 | function recordUnsupported(tool, action, phase, note) { |
| 885 | rows.push({ |
no test coverage detected