From 36fc51c124636e4a31ea11e72156a7f8facb2261 Mon Sep 17 00:00:00 2001 From: matthewp Date: Wed, 26 May 2021 15:33:35 +0000 Subject: [PATCH] [ci] yarn format --- contributing.md | 4 ++-- packages/astro/test/benchmark/benchmark.js | 22 +++++++++++-------- .../astro/test/benchmark/build-cached.json | 2 +- .../astro/test/benchmark/build-uncached.json | 2 +- packages/astro/test/benchmark/build.bench.js | 15 +++++-------- .../test/benchmark/dev-server-cached.json | 2 +- .../test/benchmark/dev-server-uncached.json | 2 +- packages/astro/test/benchmark/dev.bench.js | 12 +++++----- 8 files changed, 31 insertions(+), 30 deletions(-) diff --git a/contributing.md b/contributing.md index 5d0e9324b9..1792e89857 100644 --- a/contributing.md +++ b/contributing.md @@ -47,7 +47,7 @@ We have benchmarks to keep performance under control. You can run these by runni yarn workspace astro run benchmark ``` -Which will fail if the performance has regressed by __10%__ or more. +Which will fail if the performance has regressed by **10%** or more. To update the times cd into the `packages/astro` folder and run the following: @@ -56,4 +56,4 @@ node test/benchmark/build.bench.js --save node test/benchmark/dev.bench.js --save ``` -Which will update the build and dev benchmarks. \ No newline at end of file +Which will update the build and dev benchmarks. diff --git a/packages/astro/test/benchmark/benchmark.js b/packages/astro/test/benchmark/benchmark.js index a043ccac44..76d30e9351 100644 --- a/packages/astro/test/benchmark/benchmark.js +++ b/packages/astro/test/benchmark/benchmark.js @@ -24,11 +24,11 @@ export class Benchmark { await this.setup(); const time = await this.execute(); - - if(existsSync(file)) { + + if (existsSync(file)) { const raw = await fsPromises.readFile(file, 'utf-8'); const data = JSON.parse(raw); - if(Math.floor(data.time / time * 100) > MUST_BE_AT_LEAST_PERC_OF) { + if (Math.floor((data.time / time) * 100) > MUST_BE_AT_LEAST_PERC_OF) { this.withinPreviousRuns = true; } else { this.withinPreviousRuns = false; @@ -43,23 +43,27 @@ export class Benchmark { } check() { - if(this.withinPreviousRuns === false) { + if (this.withinPreviousRuns === false) { throw new Error(`${this.options.name} ran too slowly`); } } async save() { const { file, name } = this.options; - const data = JSON.stringify({ - name, - time: this.time - }, null, ' '); + const data = JSON.stringify( + { + name, + time: this.time, + }, + null, + ' ' + ); await fsPromises.writeFile(file, data, 'utf-8'); } async test() { await this.run(); - if(shouldSave) { + if (shouldSave) { await this.save(); } this.report(); diff --git a/packages/astro/test/benchmark/build-cached.json b/packages/astro/test/benchmark/build-cached.json index 8c83f39a5f..2ddc47c7c1 100644 --- a/packages/astro/test/benchmark/build-cached.json +++ b/packages/astro/test/benchmark/build-cached.json @@ -1,4 +1,4 @@ { "name": "Snowpack Example Build Cached", "time": 10484 -} \ No newline at end of file +} diff --git a/packages/astro/test/benchmark/build-uncached.json b/packages/astro/test/benchmark/build-uncached.json index 73df89698c..ca4f2524ad 100644 --- a/packages/astro/test/benchmark/build-uncached.json +++ b/packages/astro/test/benchmark/build-uncached.json @@ -1,4 +1,4 @@ { "name": "Snowpack Example Build Uncached", "time": 19629 -} \ No newline at end of file +} diff --git a/packages/astro/test/benchmark/build.bench.js b/packages/astro/test/benchmark/build.bench.js index 3cd1919fe2..5f9c9db2d5 100644 --- a/packages/astro/test/benchmark/build.bench.js +++ b/packages/astro/test/benchmark/build.bench.js @@ -45,12 +45,9 @@ const benchmarks = [ async setup() { process.chdir(new URL('../../../../', import.meta.url).pathname); const spcache = new URL('../../node_modules/.cache/', import.meta.url); - await Promise.all([ - del(spcache.pathname, { force: true }), - setupBuild() - ]); + await Promise.all([del(spcache.pathname, { force: true }), setupBuild()]); }, - run: runBuild + run: runBuild, }), new Benchmark({ name: 'Snowpack Example Build Cached', @@ -61,7 +58,7 @@ const benchmarks = [ await setupBuild(); await this.execute(); }, - run: runBuild + run: runBuild, }), /*new Benchmark({ name: 'Snowpack Example Dev Server Cached', @@ -75,12 +72,12 @@ const benchmarks = [ ]; async function run() { - for(const b of benchmarks) { + for (const b of benchmarks) { await b.test(); } } -run().catch(err => { +run().catch((err) => { console.error(err); process.exit(1); -}); \ No newline at end of file +}); diff --git a/packages/astro/test/benchmark/dev-server-cached.json b/packages/astro/test/benchmark/dev-server-cached.json index 3a5dffb686..e05ffc14c7 100644 --- a/packages/astro/test/benchmark/dev-server-cached.json +++ b/packages/astro/test/benchmark/dev-server-cached.json @@ -1,4 +1,4 @@ { "name": "Snowpack Example Dev Server Cached", "time": 1868 -} \ No newline at end of file +} diff --git a/packages/astro/test/benchmark/dev-server-uncached.json b/packages/astro/test/benchmark/dev-server-uncached.json index 915037f91a..71601029a2 100644 --- a/packages/astro/test/benchmark/dev-server-uncached.json +++ b/packages/astro/test/benchmark/dev-server-uncached.json @@ -1,4 +1,4 @@ { "name": "Snowpack Example Dev Server Uncached", "time": 9803 -} \ No newline at end of file +} diff --git a/packages/astro/test/benchmark/dev.bench.js b/packages/astro/test/benchmark/dev.bench.js index e2c4d3dcd9..5f222a26da 100644 --- a/packages/astro/test/benchmark/dev.bench.js +++ b/packages/astro/test/benchmark/dev.bench.js @@ -33,7 +33,7 @@ const benchmarks = [ }, run({ root }) { return runToStarted(root); - } + }, }), new Benchmark({ name: 'Snowpack Example Dev Server Cached', @@ -45,17 +45,17 @@ const benchmarks = [ }, run({ root }) { return runToStarted(root); - } - }) + }, + }), ]; async function run() { - for(const b of benchmarks) { + for (const b of benchmarks) { await b.test(); } } -run().catch(err => { +run().catch((err) => { console.error(err); process.exit(1); -}); \ No newline at end of file +});