Skip to content

Commit feadbaa

Browse files
rfrf
authored andcommitted
refactor install time
1 parent f6cf359 commit feadbaa

5 files changed

Lines changed: 36 additions & 36 deletions

File tree

packages/docs/src/components/DependencyStats.astro

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,11 @@ function formatBytesToMB(bytes: number): string {
9191
<th scope="col">Min Install</th>
9292
<th scope="col">Max Install</th>
9393
<th scope="col">Avg Cold Build</th>
94+
<th scope="col">Min Cold Build</th>
95+
<th scope="col">Max Cold Build</th>
9496
<th scope="col">Avg Warm Build</th>
97+
<th scope="col">Min Warm Build</th>
98+
<th scope="col">Max Warm Build</th>
9599
<th scope="col">Build Output</th>
96100
</tr>
97101
</thead>
@@ -100,11 +104,15 @@ function formatBytesToMB(bytes: number): string {
100104
starterStats.map((framework) => (
101105
<tr>
102106
<td class="framework-name">{framework.name}</td>
103-
<td>{(framework.avgInstallTimeMs / 1000).toFixed(2)}s</td>
104-
<td>{(framework.minInstallTimeMs / 1000).toFixed(2)}s</td>
105-
<td>{(framework.maxInstallTimeMs / 1000).toFixed(2)}s</td>
107+
<td>{(framework.installTime.avgMs / 1000).toFixed(2)}s</td>
108+
<td>{(framework.installTime.minMs / 1000).toFixed(2)}s</td>
109+
<td>{(framework.installTime.maxMs / 1000).toFixed(2)}s</td>
106110
<td>{(framework.coldBuildTime.avgMs / 1000).toFixed(2)}s</td>
111+
<td>{(framework.coldBuildTime.minMs / 1000).toFixed(2)}s</td>
112+
<td>{(framework.coldBuildTime.maxMs / 1000).toFixed(2)}s</td>
107113
<td>{(framework.warmBuildTime.avgMs / 1000).toFixed(2)}s</td>
114+
<td>{(framework.warmBuildTime.minMs / 1000).toFixed(2)}s</td>
115+
<td>{(framework.warmBuildTime.maxMs / 1000).toFixed(2)}s</td>
108116
<td>{formatBytesToMB(framework.buildOutputSize)}</td>
109117
</tr>
110118
))

packages/docs/src/content/config.ts

Lines changed: 9 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,11 @@
11
import { defineCollection, z } from 'astro:content'
22

3+
const timeSchema = z.object({
4+
avgMs: z.number(),
5+
minMs: z.number(),
6+
maxMs: z.number(),
7+
})
8+
39
const devtimeCollection = defineCollection({
410
type: 'data',
511
schema: z.object({
@@ -8,19 +14,9 @@ const devtimeCollection = defineCollection({
814
package: z.string(),
915
prodDependencies: z.number(),
1016
devDependencies: z.number(),
11-
avgInstallTimeMs: z.number(),
12-
minInstallTimeMs: z.number(),
13-
maxInstallTimeMs: z.number(),
14-
coldBuildTime: z.object({
15-
avgMs: z.number(),
16-
minMs: z.number(),
17-
maxMs: z.number(),
18-
}),
19-
warmBuildTime: z.object({
20-
avgMs: z.number(),
21-
minMs: z.number(),
22-
maxMs: z.number(),
23-
}),
17+
installTime: timeSchema,
18+
coldBuildTime: timeSchema,
19+
warmBuildTime: timeSchema,
2420
buildOutputSize: z.number(),
2521
nodeModulesSize: z.number(),
2622
nodeModulesSizeProdOnly: z.number(),

packages/stats-generator/src/run-install-benchmark.ts

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -130,9 +130,11 @@ async function main() {
130130

131131
const stats: InstallStats = {
132132
frameworkVersion,
133-
avgInstallTimeMs,
134-
minInstallTimeMs,
135-
maxInstallTimeMs,
133+
installTime: {
134+
avgMs: avgInstallTimeMs,
135+
minMs: minInstallTimeMs,
136+
maxMs: maxInstallTimeMs
137+
},
136138
nodeModulesSize,
137139
nodeModulesSizeProdOnly,
138140
}
@@ -141,9 +143,9 @@ async function main() {
141143
writeJsonFile(outputPath, stats)
142144

143145
console.info(`\n✓ Saved install stats to ${outputPath}`)
144-
console.info(` Average: ${stats.avgInstallTimeMs}ms`)
145-
console.info(` Min: ${stats.minInstallTimeMs}ms`)
146-
console.info(` Max: ${stats.maxInstallTimeMs}ms`)
146+
console.info(` Average: ${stats.installTime.avgMs}ms`)
147+
console.info(` Min: ${stats.installTime.minMs}ms`)
148+
console.info(` Max: ${stats.installTime.maxMs}ms`)
147149
} finally {
148150
rmSync(tempDir, { recursive: true, force: true })
149151
}

packages/stats-generator/src/save-ci-stats.ts

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -46,9 +46,7 @@ async function main() {
4646
stats = {
4747
...stats,
4848
frameworkVersion: installStats.frameworkVersion,
49-
avgInstallTimeMs: installStats.avgInstallTimeMs,
50-
minInstallTimeMs: installStats.minInstallTimeMs,
51-
maxInstallTimeMs: installStats.maxInstallTimeMs,
49+
installTime: installStats.installTime,
5250
nodeModulesSize: installStats.nodeModulesSize,
5351
nodeModulesSizeProdOnly: installStats.nodeModulesSizeProdOnly,
5452
}

packages/stats-generator/src/types.ts

Lines changed: 7 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -24,14 +24,12 @@ export interface CIStats {
2424
runner?: string
2525
frameworkVersion?: string
2626
// Install stats
27-
avgInstallTimeMs?: number
28-
minInstallTimeMs?: number
29-
maxInstallTimeMs?: number
27+
installTime?: TimeStat
3028
nodeModulesSize?: number
3129
nodeModulesSizeProdOnly?: number
3230
// Build stats
33-
coldBuildTime?: BuildTimeStat
34-
warmBuildTime?: BuildTimeStat
31+
coldBuildTime?: TimeStat
32+
warmBuildTime?: TimeStat
3533
buildOutputSize?: number
3634
testTimeMs?: number
3735
// SSR stats
@@ -44,20 +42,18 @@ export interface CIStats {
4442

4543
export interface InstallStats {
4644
frameworkVersion: string
47-
avgInstallTimeMs: number
48-
minInstallTimeMs: number
49-
maxInstallTimeMs: number
45+
installTime: TimeStat
5046
nodeModulesSize: number
5147
nodeModulesSizeProdOnly: number
5248
}
5349

5450
export interface BuildStats {
55-
coldBuildTime: BuildTimeStat
56-
warmBuildTime: BuildTimeStat
51+
coldBuildTime: TimeStat
52+
warmBuildTime: TimeStat
5753
buildOutputSize: number
5854
}
5955

60-
export interface BuildTimeStat {
56+
export interface TimeStat {
6157
avgMs: number
6258
minMs: number
6359
maxMs: number

0 commit comments

Comments
 (0)