| 9 | |
| 10 | |
| 11 | function toJSON(data: string): Record<string, string | number> { |
| 12 | const json: Record<string, string | number> = {}; |
| 13 | const offset = |
| 14 | data.split("\n").find((i) => i.includes("----"))?.indexOf("----") || 0; |
| 15 | for (const line of data.split("\n").filter((i) => i.trim().length)) { |
| 16 | if (line.includes(":") && !line.includes("----")) { |
| 17 | // ladybird: "Richards: 292" |
| 18 | // goja: 2025/03/29 16:43:06 DeltaBlue: 525 |
| 19 | const [k, v] = line.slice(offset) |
| 20 | .replaceAll('"', "") |
| 21 | // rhino: INFO Richards: 56.3 |
| 22 | .replaceAll("INFO ", "") |
| 23 | .split(":") |
| 24 | .map((i) => i.trim()); |
| 25 | |
| 26 | if ( |
| 27 | ![ |
| 28 | "Version", |
| 29 | "Total size", |
| 30 | "Exe size", |
| 31 | "Dll size", |
| 32 | "Richards", |
| 33 | "DeltaBlue", |
| 34 | "Crypto", |
| 35 | "RayTrace", |
| 36 | "EarleyBoyer", |
| 37 | "RegExp", |
| 38 | "Splay", |
| 39 | "NavierStokes", |
| 40 | "Score", |
| 41 | "Score/MB", |
| 42 | "Time(s)", |
| 43 | ].includes(k) |
| 44 | ) { |
| 45 | continue; |
| 46 | } |
| 47 | const n = +v; |
| 48 | json[k] = isNaN(n) ? 0 : n | 0; |
| 49 | } |
| 50 | } |
| 51 | |
| 52 | return json; |
| 53 | } |
| 54 | |
| 55 | function execCmd(cmd: string, cwd?: string) { |
| 56 | console.error(`cmd:`, { cmd, cwd }); |