summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--contributing.md4
-rw-r--r--packages/astro/test/benchmark/benchmark.js22
-rw-r--r--packages/astro/test/benchmark/build-cached.json2
-rw-r--r--packages/astro/test/benchmark/build-uncached.json2
-rw-r--r--packages/astro/test/benchmark/build.bench.js15
-rw-r--r--packages/astro/test/benchmark/dev-server-cached.json2
-rw-r--r--packages/astro/test/benchmark/dev-server-uncached.json2
-rw-r--r--packages/astro/test/benchmark/dev.bench.js12
8 files changed, 31 insertions, 30 deletions
diff --git a/contributing.md b/contributing.md
index 5d0e9324b..1792e8985 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 a043ccac4..76d30e935 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 8c83f39a5..2ddc47c7c 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 73df89698..ca4f2524a 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 3cd1919fe..5f9c9db2d 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 3a5dffb68..e05ffc14c 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 915037f91..71601029a 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 e2c4d3dcd..5f222a26d 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
+});