Skip to content

Commit

Permalink
Reduce redundant preparation in bench scripts
Browse files Browse the repository at this point in the history
  • Loading branch information
andrewiggins committed Feb 14, 2021
1 parent 2b955fc commit a27f878
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 10 deletions.
1 change: 1 addition & 0 deletions .github/workflows/benchmarks.yml
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ jobs:
npm pack --ignore-scripts
mv preact-*.tgz preact.tgz
tar -xzf preact.tgz
rm preact.tgz
- name: Upload build output
uses: actions/upload-artifact@v2
with:
Expand Down
1 change: 0 additions & 1 deletion benches/TODO.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,4 +8,3 @@
* Add bench mimicking speedometer
* Add a realworld-like bench?
* Add a specialized bench that hits certain code paths other's miss (e.g. style attribute handling?)
* Add analyze script and PR to add --trace to tachometer
8 changes: 4 additions & 4 deletions benches/scripts/config.js
Original file line number Diff line number Diff line change
Expand Up @@ -228,10 +228,6 @@ export async function generateConfig(benchPath, options) {
continue;
}

if (options.prepare !== false) {
await prepare(framework.label);
}

benchmarks.push({
...baseBenchConfig,
packageVersions: framework,
Expand All @@ -240,6 +236,10 @@ export async function generateConfig(benchPath, options) {
});
}

if (options.prepare !== false) {
await prepare(benchmarks.map(b => b.packageVersions.label));
}

/** @type {ConfigFile} */
const config = {
$schema: TACH_SCHEMA,
Expand Down
16 changes: 11 additions & 5 deletions benches/scripts/prepare.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,16 +7,22 @@ import { repoRoot } from './utils.js';
const npmCmd = process.platform == 'win32' ? 'npm.cmd' : 'npm';

/**
* @param {TachometerOptions["framework"]} framework
* @param {string[]} frameworks
*/
export async function prepare(framework) {
export async function prepare(frameworks) {
const proxyRoot = repoRoot('benches/proxy-packages');
for (let dirname of await readdir(proxyRoot)) {
if (!framework.includes(dirname.replace(/-proxy/g, ''))) {
const proxyDirs = (await readdir(proxyRoot)).map(dirname =>
dirname.replace(/-proxy$/, '')
);

for (let framework of frameworks) {
const dirname = proxyDirs.find(dir => dir == framework);
if (dirname == null) {
continue;
}

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

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

0 comments on commit a27f878

Please sign in to comment.