diff --git a/.prettierignore b/.prettierignore index 35b2b8f5..6a18c592 100644 --- a/.prettierignore +++ b/.prettierignore @@ -3,5 +3,5 @@ build/ coverage/ __benchmark_results__/ public/ - +examples CHANGELOG.md diff --git a/examples/simple_benchmark/best.config.js b/examples/simple_benchmark/best.config.js index ef4fa662..cbabe40d 100644 --- a/examples/simple_benchmark/best.config.js +++ b/examples/simple_benchmark/best.config.js @@ -1,5 +1,5 @@ module.exports = { - projectName: 'perf-best-examples', + projectName: 'simple-benchmarks', benchmarkOnClient: true, useMacroTaskAfterBenchmark: false, benchmarkRunner: '@best/runner-headless', diff --git a/examples/simple_lwc_benchmark/best.config.js b/examples/simple_lwc_benchmark/best.config.js index af3c75f8..6c28201a 100644 --- a/examples/simple_lwc_benchmark/best.config.js +++ b/examples/simple_lwc_benchmark/best.config.js @@ -1,5 +1,5 @@ module.exports = { - projectName: 'perf-best-examples', + projectName: 'lwc-examples', plugins: { 'rollup-plugin-lwc-compiler': { rootDir: '/src/', diff --git a/packages/best-cli/src/run_compare.js b/packages/best-cli/src/run_compare.js index f2e76e02..7e2e1fc9 100644 --- a/packages/best-cli/src/run_compare.js +++ b/packages/best-cli/src/run_compare.js @@ -19,7 +19,8 @@ export async function runCompare(globalConfig, configs, outputStream) { return false; } - const projectName = globalConfig.rootProjectName; + const projects = configs.map(cfg => cfg.projectName); + const projectNames = projects.length ? projects : [globalConfig.rootProjectName]; let storageProvider; try { storageProvider = require(externalStorage); @@ -28,7 +29,7 @@ export async function runCompare(globalConfig, configs, outputStream) { } preRunMessager.print('\n Fetching benchmark results to compare... \n\n', outputStream); - const compareResults = await compareBenchmarkStats(baseCommit, compareCommit, projectName, storageProvider); + const compareResults = await compareBenchmarkStats(baseCommit, compareCommit, projectNames, storageProvider); if (gitIntegration) { await pushBenchmarkComparison(baseCommit, compareCommit, compareResults, globalConfig); diff --git a/packages/best-compare/src/index.js b/packages/best-compare/src/index.js index 9b34fb74..5cadaea3 100644 --- a/packages/best-compare/src/index.js +++ b/packages/best-compare/src/index.js @@ -46,11 +46,18 @@ function compareBenchmarks(baseBenchs, targetBenchs, comparison = []) { return comparison; } -export async function compareBenchmarkStats(baseCommit, targetCommit, projectName, storageProvider) { - const [baseBenchmarks, targetBenchmarks] = await Promise.all([ - storageProvider.getAllBenchmarkStatsPerCommit(projectName, baseCommit), - storageProvider.getAllBenchmarkStatsPerCommit(projectName, targetCommit), - ]); +export async function compareBenchmarkStats(baseCommit, targetCommit, projectNames, storageProvider) { + const stats = await Promise.all( + projectNames.reduce((reducer, projectName) => [ + ...reducer, + storageProvider.getAllBenchmarkStatsPerCommit(projectName, baseCommit), + storageProvider.getAllBenchmarkStatsPerCommit(projectName, targetCommit) + ], []) + ); + + if (stats.length % 2) { + throw new Error('Recovered odd number of stats to compare'); + } preRunMessager.print('\n Running comparison... \n\n', process.stdout); @@ -60,25 +67,30 @@ export async function compareBenchmarkStats(baseCommit, targetCommit, projectNam comparison: [], }; - baseBenchmarks.forEach(baseBenchmarkBundle => { - const { benchmarkName } = baseBenchmarkBundle; - const targetBenchmarkBundle = targetBenchmarks.find(b => b.benchmarkName === benchmarkName); - if (!targetBenchmarkBundle) { - console.log(`Skipping benchmark ${benchmarkName} since we couldn't find it in commit ${targetCommit}`); - return; - } - const { version: baseVersion, environment: baseEnv, benchmarks: baseBenchs } = baseBenchmarkBundle; - const { version: targetVersion, environment: targetEnv, benchmarks: targetBenchs } = targetBenchmarkBundle; + while (stats.length) { + const baseBenchmarks = stats.shift(); + const targetBenchmarks = stats.shift(); + + baseBenchmarks.forEach(baseBenchmarkBundle => { + const { benchmarkName } = baseBenchmarkBundle; + const targetBenchmarkBundle = targetBenchmarks.find(b => b.benchmarkName === benchmarkName); + if (!targetBenchmarkBundle) { + console.log(`Skipping benchmark ${benchmarkName} since we couldn't find it in commit ${targetCommit}`); + return; + } + const { version: baseVersion, environment: baseEnv, benchmarks: baseBenchs } = baseBenchmarkBundle; + const { version: targetVersion, environment: targetEnv, benchmarks: targetBenchs } = targetBenchmarkBundle; - if (baseVersion !== targetVersion) { - console.log(`Skipping comparing ${benchmarkName} since stat versions are different`); - } + if (baseVersion !== targetVersion) { + console.log(`Skipping comparing ${benchmarkName} since stat versions are different`); + } - compareEnvironment(baseEnv, targetEnv); + compareEnvironment(baseEnv, targetEnv); - const comparison = compareBenchmarks(baseBenchs, targetBenchs); - commitComparison.comparison.push({ benchmarkName, comparison }); - }); + const comparison = compareBenchmarks(baseBenchs, targetBenchs); + commitComparison.comparison.push({ benchmarkName, comparison }); + }); + } return commitComparison; } diff --git a/packages/best-frontend/index.js b/packages/best-frontend/index.js index f5c9058f..f085fe1e 100644 --- a/packages/best-frontend/index.js +++ b/packages/best-frontend/index.js @@ -13,7 +13,7 @@ const cacheSuccesses = cache('5 minutes', onlyStatus200); // -- Middleware definition ------------------------ module.exports = function (options = {}) { const config = Object.assign({}, defaultOptions, options); - const { apiVersion, store } = config; + const { apiVersion, store, title } = config; const ApiV1 = require(`./server/api_${apiVersion}`); const storeInstance = require(store); const app = express(); @@ -31,6 +31,7 @@ module.exports = function (options = {}) { parent.get(['/', '/home'], cacheSuccesses, async (req, res) => { const projects = await storeInstance.getProjects(); res.send(template.generateHTML({ + title, projects, action: { type: 'navigateHome', page: 'home' } })); @@ -48,6 +49,7 @@ module.exports = function (options = {}) { // const stats = await statsFuture; const data = { + title, projects, // stats, selectedProject: projectName, diff --git a/packages/best-frontend/serve.js b/packages/best-frontend/serve.js index e68dcab3..030cbf4b 100644 --- a/packages/best-frontend/serve.js +++ b/packages/best-frontend/serve.js @@ -12,6 +12,7 @@ const PORT = process.env.PORT || 3000; const app = express(); const config = { + title: 'Best', // store: "@best/store-aws", storeConfig: { // Config shall be passed as env parameters diff --git a/packages/best-frontend/src/modules/one/app/app.html b/packages/best-frontend/src/modules/one/app/app.html index efa1ffae..f631c6ce 100644 --- a/packages/best-frontend/src/modules/one/app/app.html +++ b/packages/best-frontend/src/modules/one/app/app.html @@ -21,7 +21,7 @@
- +
diff --git a/packages/best-frontend/src/modules/one/app/utils.js b/packages/best-frontend/src/modules/one/app/utils.js index 99145f39..949a0350 100644 --- a/packages/best-frontend/src/modules/one/app/utils.js +++ b/packages/best-frontend/src/modules/one/app/utils.js @@ -63,8 +63,9 @@ export function normalizeStats(state, stats, project, branch) { } export function initializeState(state, serverState) { - const { action, stats, projects, branches, selectedProject, selectedBranch} = serverState; + const { action, stats, projects, branches, selectedProject, selectedBranch, title } = serverState; const navItems = projects.map(p => buildNavItem(p)); + state.title = title; state.projects = projects; // eslint-disable-next-line no-return-assign, no-sequences state.branches = projects.reduce((r, p) => (r[p] = ['master'], r), {});