Skip to content

Commit 0cd388c

Browse files
committed
refactor: Clean up benchmark comparisons and update moonrepo configuration
- Removed hardcoded comparisons in benchmark results and replaced with dynamic calculations for faster tools. - Updated benchmark-json.ts to streamline the benchmarking process by eliminating unnecessary comparisons. - Adjusted .moon/workspace.yml to simplify project globs. - Updated pnpm-lock.yaml to reflect the latest version of '@emnapi/runtime'. - Enhanced compare-and-update-readme.ts to include dynamic comparison results in the README. This improves maintainability and accuracy of benchmark results.
1 parent 5daec04 commit 0cd388c

File tree

5 files changed

+35
-49
lines changed

5 files changed

+35
-49
lines changed

.moon/workspace.yml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@ $schema: 'https://moonrepo.dev/schemas/workspace.json'
33
projects:
44
globs:
55
- './apps/*'
6-
- './packages/*/*'
76

87
vcs:
98
provider: 'github'

benchmark-json.ts

Lines changed: 0 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -333,16 +333,7 @@ function runBenchmark(): BenchmarkResults {
333333
lage: { average: 0, total: 0, runs: [], min: 0, max: 0 },
334334
moon: { average: 0, total: 0, runs: [], min: 0, max: 0 },
335335
},
336-
<<<<<<< HEAD
337-
comparisons: {
338-
nxVsLage: 0,
339-
nxVsTurbo: 0,
340-
nxVsLerna: 0,
341-
nxVsMoon: 0,
342-
},
343-
=======
344336
comparisons: {},
345-
>>>>>>> 72e4fd0fcad0fb81b6a5d2739fb095fe2375d8fd
346337
};
347338

348339
// Run turbo benchmark
@@ -412,25 +403,6 @@ function runBenchmark(): BenchmarkResults {
412403
);
413404

414405
// Run moon benchmark
415-
<<<<<<< HEAD
416-
results.tools.moon = runToolBenchmark(
417-
[
418-
{ cmd: 'moon', args: ['run', ':build', '--concurrency=3'] },
419-
{ cmd: 'moon', args: ['run', ':build', '--concurrency=3'] },
420-
],
421-
{ cmd: 'moon', args: ['run', ':build', '--concurrency=10'] },
422-
'moon'
423-
);
424-
425-
// Calculate comparisons
426-
const { nx, turbo, lerna, lage, moon } = results.tools;
427-
results.comparisons = {
428-
nxVsLage: lage.average / nx.average,
429-
nxVsTurbo: turbo.average / nx.average,
430-
nxVsLerna: lerna.average / nx.average,
431-
nxVsMoon: moon.average / nx.average,
432-
};
433-
=======
434406
console.log(`\n[5/5] Starting Moon benchmark...`);
435407
results.tools.moon = runToolBenchmark(
436408
{
@@ -504,7 +476,6 @@ function runBenchmark(): BenchmarkResults {
504476
console.log(` ${indicator} ${tool}: ${ratio.toFixed(2)}x (${change})`);
505477
}
506478
});
507-
>>>>>>> 72e4fd0fcad0fb81b6a5d2739fb095fe2375d8fd
508479

509480
return results;
510481
}

pnpm-lock.yaml

Lines changed: 2 additions & 10 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

scripts/compare-and-update-readme.ts

Lines changed: 22 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,27 @@ function formatResults(results: BenchmarkResults): string {
3333
day: 'numeric',
3434
});
3535

36+
// Find the fastest tool
37+
const toolEntries = Object.entries(results.tools).map(([name, data]) => ({
38+
name,
39+
average: data.average,
40+
}));
41+
42+
const fastestTool = toolEntries.reduce((fastest, current) =>
43+
current.average < fastest.average ? current : fastest
44+
);
45+
46+
// Generate dynamic comparisons
47+
const comparisons = toolEntries
48+
.filter((tool) => tool.name !== fastestTool.name)
49+
.map((tool) => {
50+
const ratio = (tool.average / fastestTool.average).toFixed(1);
51+
const toolLabel =
52+
tool.name === 'lerna' ? 'lerna (powered by nx)' : tool.name;
53+
return `* ${fastestTool.name} is ${ratio}x faster than ${toolLabel}`;
54+
})
55+
.join('\n');
56+
3657
return `## Benchmark & Results (${date})
3758
3859
Run \`pnpm run benchmark\`. The benchmark will warm the cache of all the tools. We benchmark how quickly
@@ -47,12 +68,7 @@ These are the numbers using GitHub Actions runner:
4768
)}
4869
* average moon time is: ${results.tools.moon.average.toFixed(1)}
4970
* average nx time is: ${results.tools.nx.average.toFixed(1)}
50-
* nx is ${results.comparisons.nxVsLage.toFixed(1)}x faster than lage
51-
* nx is ${results.comparisons.nxVsTurbo.toFixed(1)}x faster than turbo
52-
* nx is ${results.comparisons.nxVsLerna.toFixed(
53-
1
54-
)}x faster than lerna (powered by nx)
55-
* nx is ${results.comparisons.nxVsMoon.toFixed(1)}x faster than moon`;
71+
${comparisons}`;
5672
}
5773

5874
function updateReadme(newResults: BenchmarkResults): boolean {

scripts/test-compare.ts

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
import {
2-
parseResults,
3-
isSignificantChange,
4-
formatResults,
52
detectPerformanceRegression,
3+
formatResults,
4+
isSignificantChange,
5+
parseResults,
66
shouldUpdateReadme,
77
} from './compare-and-update-readme';
88
import type { BenchmarkResults } from './types';
@@ -41,6 +41,13 @@ const currentResults: BenchmarkResults = {
4141
min: 9500,
4242
max: 9900,
4343
},
44+
moon: {
45+
average: 5500.0,
46+
total: 55000,
47+
runs: [5400, 5600, 5500, 5450, 5550, 5520, 5480, 5510, 5530, 5470],
48+
min: 5400,
49+
max: 5600,
50+
},
4451
},
4552
comparisons: {
4653
nxVsLage: 27.15,
@@ -58,6 +65,7 @@ const previousResults: BenchmarkResults = {
5865
turbo: { average: 4500.0, total: 45000, runs: [], min: 4400, max: 4600 },
5966
lerna: { average: 1750.0, total: 17500, runs: [], min: 1700, max: 1800 },
6067
lage: { average: 9500.0, total: 95000, runs: [], min: 9400, max: 9600 },
68+
moon: { average: 5400.0, total: 54000, runs: [], min: 5300, max: 5500 },
6169
},
6270
comparisons: {
6371
nxVsLage: 27.14,

0 commit comments

Comments
 (0)