|
1 |
| -import * as fs from 'fs'; |
2 |
| -import * as path from 'path'; |
| 1 | +import * as fs from 'node:fs'; |
| 2 | +import * as path from 'node:path'; |
3 | 3 | import type { BenchmarkResults, ComparisonOutputs, ToolName } from './types';
|
4 | 4 |
|
5 | 5 | // Threshold for significant performance change (10%)
|
@@ -54,20 +54,26 @@ function formatResults(results: BenchmarkResults): string {
|
54 | 54 | })
|
55 | 55 | .join('\n');
|
56 | 56 |
|
| 57 | + // Generate tool results list dynamically based on available tools |
| 58 | + const toolOrder = ['lage', 'turbo', 'lerna', 'moon', 'nx']; |
| 59 | + const toolResults = toolOrder |
| 60 | + .filter((tool) => results.tools[tool as ToolName]) |
| 61 | + .map((tool) => { |
| 62 | + const toolLabel = tool === 'lerna' ? 'lerna (powered by nx)' : tool; |
| 63 | + return `* average ${toolLabel} time is: ${results.tools[ |
| 64 | + tool as ToolName |
| 65 | + ].average.toFixed(1)}`; |
| 66 | + }) |
| 67 | + .join('\n'); |
| 68 | + |
57 | 69 | return `## Benchmark & Results (${date})
|
58 | 70 |
|
59 | 71 | Run \`pnpm run benchmark\`. The benchmark will warm the cache of all the tools. We benchmark how quickly
|
60 | 72 | Turbo/Nx/Lerna/Lage/Moon can figure out what needs to be restored from the cache and restores it.
|
61 | 73 |
|
62 | 74 | These are the numbers using GitHub Actions runner:
|
63 | 75 |
|
64 |
| -* average lage time is: ${results.tools.lage.average.toFixed(1)} |
65 |
| -* average turbo time is: ${results.tools.turbo.average.toFixed(1)} |
66 |
| -* average lerna (powered by nx) time is: ${results.tools.lerna.average.toFixed( |
67 |
| - 1 |
68 |
| - )} |
69 |
| -* average moon time is: ${results.tools.moon.average.toFixed(1)} |
70 |
| -* average nx time is: ${results.tools.nx.average.toFixed(1)} |
| 76 | +${toolResults} |
71 | 77 | ${comparisons}`;
|
72 | 78 | }
|
73 | 79 |
|
@@ -232,11 +238,15 @@ function main(): ComparisonOutputs {
|
232 | 238 |
|
233 | 239 | // Log current results for debugging
|
234 | 240 | console.log('Current benchmark results:');
|
235 |
| - console.log(`- NX: ${currentResults.tools.nx.average.toFixed(1)}ms`); |
236 |
| - console.log(`- Turbo: ${currentResults.tools.turbo.average.toFixed(1)}ms`); |
237 |
| - console.log(`- Lerna: ${currentResults.tools.lerna.average.toFixed(1)}ms`); |
238 |
| - console.log(`- Lage: ${currentResults.tools.lage.average.toFixed(1)}ms`); |
239 |
| - console.log(`- Moon: ${currentResults.tools.moon.average.toFixed(1)}ms`); |
| 241 | + const availableTools: ToolName[] = ['nx', 'turbo', 'lerna', 'lage', 'moon']; |
| 242 | + availableTools.forEach((tool) => { |
| 243 | + if (currentResults.tools[tool]) { |
| 244 | + const toolLabel = tool.toUpperCase(); |
| 245 | + console.log( |
| 246 | + `- ${toolLabel}: ${currentResults.tools[tool].average.toFixed(1)}ms` |
| 247 | + ); |
| 248 | + } |
| 249 | + }); |
240 | 250 |
|
241 | 251 | return {
|
242 | 252 | readmeUpdated: shouldUpdate,
|
|
0 commit comments