mirror of
https://github.com/withastro/astro.git
synced 2024-12-16 21:46:22 -05:00
Improve stress test benchmark (#8225)
This commit is contained in:
parent
acf652fc1d
commit
0ae3b7a7ba
2 changed files with 17 additions and 3 deletions
|
@ -1,6 +1,9 @@
|
|||
import { createRequire } from 'module';
|
||||
import { createRequire } from 'node:module';
|
||||
import path from 'node:path';
|
||||
|
||||
export const astroBin = createRequire(import.meta.url).resolve('astro');
|
||||
const astroPkgPath = createRequire(import.meta.url).resolve('astro/package.json');
|
||||
|
||||
export const astroBin = path.resolve(astroPkgPath, '../astro.js');
|
||||
|
||||
/** @typedef {{ avg: number, stdev: number, max: number }} Stat */
|
||||
|
||||
|
|
|
@ -7,11 +7,13 @@ import { loremIpsum } from './_util.js';
|
|||
export async function run(projectDir) {
|
||||
await fs.rm(projectDir, { recursive: true, force: true });
|
||||
await fs.mkdir(new URL('./src/pages', projectDir), { recursive: true });
|
||||
await fs.mkdir(new URL('./src/components', projectDir), { recursive: true });
|
||||
|
||||
await fs.writeFile(
|
||||
new URL('./src/pages/index.astro', projectDir),
|
||||
`\
|
||||
---
|
||||
import Paragraph from '../components/Paragraph.astro'
|
||||
const content = "${loremIpsum}"
|
||||
---
|
||||
|
||||
|
@ -25,13 +27,22 @@ const content = "${loremIpsum}"
|
|||
<body>
|
||||
<h1>Astro</h1>
|
||||
<div>
|
||||
${Array.from({ length: 60 }).map(() => '<p>{content}</p>')}
|
||||
${Array.from({ length: 100 }).map(() => '<p>{content}</p>').join('\n')}
|
||||
</div>
|
||||
<div>
|
||||
${Array.from({ length: 50 }).map((_, i) => '<Paragraph num={' + i + '} str={content} />').join('\n')}
|
||||
</div>
|
||||
</body>
|
||||
</html>`,
|
||||
'utf-8'
|
||||
);
|
||||
|
||||
await fs.writeFile(
|
||||
new URL('./src/components/Paragraph.astro', projectDir),
|
||||
`<div>{Astro.props.num} {Astro.props.str}</div>`,
|
||||
'utf-8'
|
||||
);
|
||||
|
||||
await fs.writeFile(
|
||||
new URL('./astro.config.js', projectDir),
|
||||
`\
|
||||
|
|
Loading…
Reference in a new issue