-
-
Notifications
You must be signed in to change notification settings - Fork 2.5k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'main' into view-transitions
- Loading branch information
Showing
103 changed files
with
919 additions
and
367 deletions.
There are no files selected for viewing
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,18 @@ | ||
import { createRequire } from 'module'; | ||
|
||
export const astroBin = createRequire(import.meta.url).resolve('astro'); | ||
|
||
/** @typedef {{ avg: number, stdev: number, max: number }} Stat */ | ||
|
||
/** | ||
* @param {number[]} numbers | ||
* @returns {Stat} | ||
*/ | ||
export function calculateStat(numbers) { | ||
const avg = numbers.reduce((a, b) => a + b, 0) / numbers.length; | ||
const stdev = Math.sqrt( | ||
numbers.map((x) => Math.pow(x - avg, 2)).reduce((a, b) => a + b, 0) / numbers.length | ||
); | ||
const max = Math.max(...numbers); | ||
return { avg, stdev, max }; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,73 @@ | ||
import { fileURLToPath } from 'url'; | ||
import { execaCommand } from 'execa'; | ||
import { markdownTable } from 'markdown-table'; | ||
import { astroBin, calculateStat } from './_util.js'; | ||
|
||
/** Default project to run for this benchmark if not specified */ | ||
export const defaultProject = 'render-default'; | ||
|
||
/** | ||
* @param {URL} projectDir | ||
* @param {URL} outputFile | ||
*/ | ||
export async function run(projectDir, outputFile) { | ||
const root = fileURLToPath(projectDir); | ||
|
||
console.log('Benchmarking `astro --help`...'); | ||
const helpStat = await benchmarkCommand(`node ${astroBin} --help`, root); | ||
console.log('Done'); | ||
|
||
console.log('Benchmarking `astro info`...'); | ||
const infoStat = await benchmarkCommand(`node ${astroBin} info`, root); | ||
console.log('Done'); | ||
|
||
console.log('Result preview:'); | ||
console.log('='.repeat(10)); | ||
console.log(`#### CLI Startup\n\n`); | ||
console.log( | ||
printResult({ | ||
'astro --help': helpStat, | ||
'astro info': infoStat, | ||
}) | ||
); | ||
console.log('='.repeat(10)); | ||
} | ||
|
||
/** | ||
* @param {string} command | ||
* @param {string} root | ||
* @returns {Promise<import('./_util.js').Stat>} | ||
*/ | ||
async function benchmarkCommand(command, root) { | ||
/** @type {number[]} */ | ||
const durations = []; | ||
|
||
for (let i = 0; i < 10; i++) { | ||
const start = performance.now(); | ||
await execaCommand(command, { cwd: root }); | ||
durations.push(performance.now() - start); | ||
} | ||
|
||
// From the 10 durations, calculate average, standard deviation, and max value | ||
return calculateStat(durations); | ||
} | ||
|
||
/** | ||
* @param {Record<string, import('./_util.js').Stat>} result | ||
*/ | ||
function printResult(result) { | ||
return markdownTable( | ||
[ | ||
['Command', 'Avg (ms)', 'Stdev (ms)', 'Max (ms)'], | ||
...Object.entries(result).map(([command, { avg, stdev, max }]) => [ | ||
command, | ||
avg.toFixed(2), | ||
stdev.toFixed(2), | ||
max.toFixed(2), | ||
]), | ||
], | ||
{ | ||
align: ['l', 'r', 'r', 'r'], | ||
} | ||
); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -11,6 +11,6 @@ | |
"astro": "astro" | ||
}, | ||
"dependencies": { | ||
"astro": "^2.7.4" | ||
"astro": "^2.8.1" | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -12,7 +12,7 @@ | |
}, | ||
"dependencies": { | ||
"@astrojs/svelte": "^3.1.0", | ||
"astro": "^2.7.4", | ||
"astro": "^2.8.1", | ||
"svelte": "^3.59.1" | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -12,7 +12,7 @@ | |
}, | ||
"dependencies": { | ||
"@astrojs/vue": "^2.2.1", | ||
"astro": "^2.7.4", | ||
"astro": "^2.8.1", | ||
"vue": "^3.3.4" | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -12,6 +12,6 @@ | |
}, | ||
"dependencies": { | ||
"@astrojs/node": "^5.3.0", | ||
"astro": "^2.7.4" | ||
"astro": "^2.8.1" | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.