Skip to content

Commit a27f878

Browse files
committed
Reduce redundant preparation in bench scripts
1 parent 2b955fc commit a27f878

File tree

4 files changed

+16
-10
lines changed

4 files changed

+16
-10
lines changed

.github/workflows/benchmarks.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,7 @@ jobs:
4242
npm pack --ignore-scripts
4343
mv preact-*.tgz preact.tgz
4444
tar -xzf preact.tgz
45+
rm preact.tgz
4546
- name: Upload build output
4647
uses: actions/upload-artifact@v2
4748
with:

benches/TODO.md

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,4 +8,3 @@
88
* Add bench mimicking speedometer
99
* Add a realworld-like bench?
1010
* Add a specialized bench that hits certain code paths other's miss (e.g. style attribute handling?)
11-
* Add analyze script and PR to add --trace to tachometer

benches/scripts/config.js

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -228,10 +228,6 @@ export async function generateConfig(benchPath, options) {
228228
continue;
229229
}
230230

231-
if (options.prepare !== false) {
232-
await prepare(framework.label);
233-
}
234-
235231
benchmarks.push({
236232
...baseBenchConfig,
237233
packageVersions: framework,
@@ -240,6 +236,10 @@ export async function generateConfig(benchPath, options) {
240236
});
241237
}
242238

239+
if (options.prepare !== false) {
240+
await prepare(benchmarks.map(b => b.packageVersions.label));
241+
}
242+
243243
/** @type {ConfigFile} */
244244
const config = {
245245
$schema: TACH_SCHEMA,

benches/scripts/prepare.js

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -7,16 +7,22 @@ import { repoRoot } from './utils.js';
77
const npmCmd = process.platform == 'win32' ? 'npm.cmd' : 'npm';
88

99
/**
10-
* @param {TachometerOptions["framework"]} framework
10+
* @param {string[]} frameworks
1111
*/
12-
export async function prepare(framework) {
12+
export async function prepare(frameworks) {
1313
const proxyRoot = repoRoot('benches/proxy-packages');
14-
for (let dirname of await readdir(proxyRoot)) {
15-
if (!framework.includes(dirname.replace(/-proxy/g, ''))) {
14+
const proxyDirs = (await readdir(proxyRoot)).map(dirname =>
15+
dirname.replace(/-proxy$/, '')
16+
);
17+
18+
for (let framework of frameworks) {
19+
const dirname = proxyDirs.find(dir => dir == framework);
20+
if (dirname == null) {
1621
continue;
1722
}
1823

19-
const proxyDir = (...args) => path.join(proxyRoot, dirname, ...args);
24+
const proxyDir = (...args) =>
25+
path.join(proxyRoot, dirname + '-proxy', ...args);
2026

2127
// It appears from ad-hoc testing (npm v6.14.9 on Windows), npm will cache
2228
// any locally referenced tarball files (e.g. "file:../../../preact.tgz") in

0 commit comments

Comments
 (0)