[ci] yarn format
This commit is contained in:
parent
da47225efe
commit
36fc51c124
8 changed files with 31 additions and 30 deletions
|
@ -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.
|
||||
Which will update the build and dev benchmarks.
|
||||
|
|
|
@ -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();
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
{
|
||||
"name": "Snowpack Example Build Cached",
|
||||
"time": 10484
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
{
|
||||
"name": "Snowpack Example Build Uncached",
|
||||
"time": 19629
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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);
|
||||
});
|
||||
});
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
{
|
||||
"name": "Snowpack Example Dev Server Cached",
|
||||
"time": 1868
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
{
|
||||
"name": "Snowpack Example Dev Server Uncached",
|
||||
"time": 9803
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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);
|
||||
});
|
||||
});
|
||||
|
|
Loading…
Reference in a new issue