Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Create separate trace log directories per benchmark #3024

Merged
merged 2 commits into from
Feb 16, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions benches/.gitignore
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
dist/
results/
logs/
logs-saved/
node_modules/
proxy-packages/*/package-lock.json
66 changes: 51 additions & 15 deletions benches/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions benches/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
"escalade": "^3.0.2",
"escape-string-regexp": "^4.0.0",
"globby": "^11.0.0",
"prompts": "^2.4.0",
"sade": "^1.7.3",
"strip-ansi": "^6.0.0",
"tachometer": "^0.5.7",
Expand Down
37 changes: 33 additions & 4 deletions benches/scripts/analyze.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import { existsSync } from 'fs';
import { readFile, readdir } from 'fs/promises';
import { frameworks } from './config.js';
import { benchesRoot } from './utils.js';
import prompts from 'prompts';
import { baseTraceLogDir, frameworks } from './config.js';

// @ts-ignore
import tachometerStats from 'tachometer/lib/stats.js';
Expand Down Expand Up @@ -290,15 +291,43 @@ export async function analyze() {
'duration'
];

if (!existsSync(baseTraceLogDir())) {
console.log(
`Could not find log directory: "${baseTraceLogDir()}". Did you run the benchmarks?`
);
return;
}

const benchmarkNames = await readdir(baseTraceLogDir());
let selectedBench;
if (benchmarkNames.length == 0) {
console.log(`No benchmarks or results found in "${baseTraceLogDir()}".`);
return;
} else if (benchmarkNames.length == 1) {
selectedBench = benchmarkNames[0];
} else {
selectedBench = (
await prompts({
type: 'select',
name: 'value',
message: "Which benchmark's results would you like to analyze?",
choices: benchmarkNames.map(name => ({
title: name,
value: name
}))
})
).value;
}

/** @type {Map<string, ResultStats[]>} */
const resultStatsMap = new Map();
for (let framework of frameworkNames) {
const logDir = benchesRoot('logs', framework);
const logDir = baseTraceLogDir(selectedBench, framework);

let logFilePaths;
try {
logFilePaths = (await readdir(logDir)).map(fn =>
benchesRoot('logs', framework, fn)
baseTraceLogDir(selectedBench, framework, fn)
);
} catch (e) {
// If directory doesn't exist or we fail to read it, just skip
Expand Down
8 changes: 8 additions & 0 deletions benches/scripts/bench.js
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,14 @@ export const defaultBenchOptions = {
export async function runBenches(bench1 = 'all', opts) {
const globs = bench1 === 'all' ? allBenches : [bench1].concat(opts._);
const benchesToRun = await globSrc(globs);

if (benchesToRun.length == 0) {
console.log('No benchmarks found matching patterns:', globs);
} else {
console.log('Running benchmarks:', benchesToRun.join(', '));
console.log();
}

const configFileTasks = benchesToRun.map(async (benchPath, i) => {
return generateConfig(benchesRoot('src', benchPath), {
...opts,
Expand Down
4 changes: 3 additions & 1 deletion benches/scripts/config.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,8 @@ const warnings = new Set([]);
const TACH_SCHEMA =
'https://raw.githubusercontent.com/Polymer/tachometer/master/config.schema.json';

const traceLogDir = benchesRoot('logs');
export const baseTraceLogDir = (...args) =>
path.join(benchesRoot('logs'), ...args);

/**
* @param {ConfigFileBenchmark["packageVersions"]["dependencies"]["framework"]} framework
Expand Down Expand Up @@ -171,6 +172,7 @@ export async function generateConfig(benchPath, options) {
}

if (browser.name == 'chrome' && options.trace) {
const traceLogDir = baseTraceLogDir(baseBenchConfig.name);
await del('**/*', { cwd: traceLogDir });
await mkdir(traceLogDir, { recursive: true });

Expand Down