@@ -6,7 +6,8 @@ import { readFile, writeFile } from 'node:fs/promises';
6
6
const ROOT = new URL ( '..' , import . meta. url ) . pathname ;
7
7
$ . verbose = true ;
8
8
9
- const REUSE_CONTROL = ! ! process . env [ 'REUSE_CONTROL' ] ;
9
+ const REUSE_CONTROL = ! ! ( process . env [ 'REUSE_DIRS' ] || process . env [ 'REUSE_CONTROL' ] ) ;
10
+ const REUSE_EXPERIMENT = ! ! ( process . env [ 'REUSE_DIRS' ] || process . env [ 'REUSE_EXPERIMENT' ] ) ;
10
11
11
12
/*
12
13
@@ -81,8 +82,10 @@ if (!REUSE_CONTROL) {
81
82
await $ `mkdir ${ CONTROL_DIR } ` ;
82
83
}
83
84
84
- await $ `rm -rf ${ EXPERIMENT_DIR } ` ;
85
- await $ `mkdir ${ EXPERIMENT_DIR } ` ;
85
+ if ( ! REUSE_EXPERIMENT ) {
86
+ await $ `rm -rf ${ EXPERIMENT_DIR } ` ;
87
+ await $ `mkdir ${ EXPERIMENT_DIR } ` ;
88
+ }
86
89
87
90
// Intentionally use the same folder for both experiment and control to make it easier to
88
91
// make changes to the benchmark suite itself and compare the results.
@@ -138,16 +141,10 @@ console.info({
138
141
} ) ;
139
142
140
143
// setup experiment
141
- await within ( async ( ) => {
142
- await buildRepo ( EXPERIMENT_DIR , experimentRef ) ;
143
- } ) ;
144
+ await buildRepo ( EXPERIMENT_DIR , experimentRef , REUSE_EXPERIMENT ) ;
144
145
145
- if ( ! REUSE_CONTROL ) {
146
- // setup control
147
- await within ( async ( ) => {
148
- await buildRepo ( CONTROL_DIR , controlRef ) ;
149
- } ) ;
150
- }
146
+ // setup control
147
+ await buildRepo ( CONTROL_DIR , controlRef , REUSE_CONTROL ) ;
151
148
152
149
// start build assets
153
150
$ `cd ${ CONTROL_BENCH_DIR } && pnpm vite preview --port ${ CONTROL_PORT } ` ;
@@ -177,36 +174,48 @@ process.exit(0);
177
174
/**
178
175
* @param {string } directory the directory to clone into
179
176
* @param {string } ref the ref to checkout
177
+ * @param {boolean } reuse reuse the existing directory
180
178
*/
181
- async function buildRepo ( directory , ref ) {
182
- // the benchmark directory is located in `packages/@glimmer/benchmark` in each of the
183
- // experiment and control checkouts
184
- const benchDir = join ( directory , 'benchmark' , 'benchmarks' , 'krausest' ) ;
179
+ async function buildRepo ( directory , ref , reuse ) {
180
+ if ( ! reuse ) {
181
+ await $ `rm -rf ${ directory } ` ;
182
+ await $ `mkdir ${ directory } ` ;
183
+ }
185
184
186
- await cd ( directory ) ;
185
+ await within ( async ( ) => {
186
+ // the benchmark directory is located in `packages/@glimmer/benchmark` in each of the
187
+ // experiment and control checkouts
188
+ const benchDir = join ( directory , 'benchmark' , 'benchmarks' , 'krausest' ) ;
187
189
188
- // write the `pwd` to the output to make it easier to debug if something goes wrong
189
- await $ `pwd` ;
190
+ await cd ( directory ) ;
190
191
191
- // clone the raw git repo for the experiment
192
- await $ `git clone ${ join ( ROOT , '.git' ) } . `;
192
+ // write the `pwd` to the output to make it easier to debug if something goes wrong
193
+ await $ `pwd `;
193
194
194
- // checkout the repo to the HEAD of the current branch
195
- await $ `git checkout --force ${ ref } ` ;
195
+ if ( reuse ) {
196
+ await $ `git fetch` ;
197
+ } else {
198
+ // clone the raw git repo for the experiment
199
+ await $ `git clone ${ join ( ROOT , '.git' ) } .` ;
200
+ }
196
201
197
- // recreate the benchmark directory
198
- await $ `rm -rf ./benchmark` ;
199
- // intentionally use the same folder for both experiment and control
200
- await $ `cp -r ${ BENCHMARK_FOLDER } ./benchmark` ;
202
+ // checkout the repo to the HEAD of the current branch
203
+ await $ `git checkout --force ${ ref } ` ;
201
204
202
- // `pnpm install` and build the repo
203
- await $ `pnpm install --no-frozen-lockfile` ;
204
- await $ `pnpm build` ;
205
+ // recreate the benchmark directory
206
+ await $ `rm -rf ./benchmark` ;
207
+ // intentionally use the same folder for both experiment and control
208
+ await $ `cp -r ${ BENCHMARK_FOLDER } ./benchmark` ;
205
209
206
- // rewrite all `package.json`s to behave like published packages
207
- await rewritePackageJson ( ) ;
210
+ // `pnpm install` and build the repo
211
+ await $ `pnpm install --no-frozen-lockfile` ;
212
+ await $ `pnpm build` ;
208
213
209
- // build the benchmarks using vite
210
- await cd ( benchDir ) ;
211
- await $ `pnpm vite build` ;
214
+ // rewrite all `package.json`s to behave like published packages
215
+ await rewritePackageJson ( ) ;
216
+
217
+ // build the benchmarks using vite
218
+ await cd ( benchDir ) ;
219
+ await $ `pnpm vite build` ;
220
+ } ) ;
212
221
}
0 commit comments