chore: add --format
flag to benchmark
This commit is contained in:
parent
b6f752a3ee
commit
67e4746ec1
1 changed files with 29 additions and 6 deletions
|
@ -47,10 +47,19 @@ async function benchmark({ fixtures, templates }) {
|
||||||
? [flags.test]
|
? [flags.test]
|
||||||
: ['simple', 'with-astro-components', 'with-react-components'];
|
: ['simple', 'with-astro-components', 'with-react-components'];
|
||||||
|
|
||||||
|
const formats = Array.isArray(flags.format)
|
||||||
|
? flags.format
|
||||||
|
: typeof flags.format === 'string'
|
||||||
|
? [flags.format]
|
||||||
|
: ['md', 'mdx', 'mdoc'];
|
||||||
|
|
||||||
if (test.includes('simple')) {
|
if (test.includes('simple')) {
|
||||||
console.log(`\n${bold('Simple')} ${dim(`${NUM_POSTS} posts (md, mdx, mdoc)`)}`);
|
const fixtures = formats;
|
||||||
|
console.log(
|
||||||
|
`\n${bold('Simple')} ${dim(`${NUM_POSTS} posts (${formatsToString(fixtures)})`)}`
|
||||||
|
);
|
||||||
await benchmark({
|
await benchmark({
|
||||||
fixtures: ['md', 'mdx', 'mdoc'],
|
fixtures,
|
||||||
templates: {
|
templates: {
|
||||||
md: 'simple.md',
|
md: 'simple.md',
|
||||||
mdx: 'simple.md',
|
mdx: 'simple.md',
|
||||||
|
@ -60,9 +69,14 @@ async function benchmark({ fixtures, templates }) {
|
||||||
}
|
}
|
||||||
|
|
||||||
if (test.includes('with-astro-components')) {
|
if (test.includes('with-astro-components')) {
|
||||||
console.log(`\n${bold('With Astro components')} ${dim(`${NUM_POSTS} posts (mdx, mdoc)`)}`);
|
const fixtures = formats.filter((format) => format !== 'md');
|
||||||
|
console.log(
|
||||||
|
`\n${bold('With Astro components')} ${dim(
|
||||||
|
`${NUM_POSTS} posts (${formatsToString(fixtures)})`
|
||||||
|
)}`
|
||||||
|
);
|
||||||
await benchmark({
|
await benchmark({
|
||||||
fixtures: ['mdx', 'mdoc'],
|
fixtures,
|
||||||
templates: {
|
templates: {
|
||||||
mdx: 'with-astro-components.mdx',
|
mdx: 'with-astro-components.mdx',
|
||||||
mdoc: 'with-astro-components.mdoc',
|
mdoc: 'with-astro-components.mdoc',
|
||||||
|
@ -71,9 +85,14 @@ async function benchmark({ fixtures, templates }) {
|
||||||
}
|
}
|
||||||
|
|
||||||
if (test.includes('with-react-components')) {
|
if (test.includes('with-react-components')) {
|
||||||
console.log(`\n${bold('With React components')} ${dim(`${NUM_POSTS} posts (mdx, mdoc)`)}`);
|
const fixtures = formats.filter((format) => format !== 'md');
|
||||||
|
console.log(
|
||||||
|
`\n${bold('With React components')} ${dim(
|
||||||
|
`${NUM_POSTS} posts (${formatsToString(fixtures)})`
|
||||||
|
)}`
|
||||||
|
);
|
||||||
await benchmark({
|
await benchmark({
|
||||||
fixtures: ['mdx', 'mdoc'],
|
fixtures,
|
||||||
templates: {
|
templates: {
|
||||||
mdx: 'with-react-components.mdx',
|
mdx: 'with-react-components.mdx',
|
||||||
mdoc: 'with-react-components.mdoc',
|
mdoc: 'with-react-components.mdoc',
|
||||||
|
@ -89,3 +108,7 @@ function getTimeStat(timeStart, timeEnd) {
|
||||||
const buildTime = timeEnd - timeStart;
|
const buildTime = timeEnd - timeStart;
|
||||||
return buildTime < 750 ? `${Math.round(buildTime)}ms` : `${(buildTime / 1000).toFixed(2)}s`;
|
return buildTime < 750 ? `${Math.round(buildTime)}ms` : `${(buildTime / 1000).toFixed(2)}s`;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function formatsToString(formats) {
|
||||||
|
return formats.join(', ');
|
||||||
|
}
|
||||||
|
|
Loading…
Reference in a new issue