fix benchmark script (#66789)
### What? * fix CLI output regex for updates text * bench all scenarios * bench correct folder * make an real change instead of only a comment
This commit is contained in:
parent
5346185d37
commit
50c7e939b6
7 changed files with 111 additions and 84 deletions
|
@ -6,7 +6,7 @@ import Comp from '../../components/index.jsx'
|
|||
export default function Home() {
|
||||
return (
|
||||
<>
|
||||
<h1>Hello!!!!!!!!!!!!</h1>
|
||||
<h1>Hello!</h1>
|
||||
<Comp />
|
||||
</>
|
||||
)
|
||||
|
|
|
@ -4,5 +4,10 @@ import React from 'react'
|
|||
import Comp from '../../components/index.jsx'
|
||||
|
||||
export default function Home() {
|
||||
return <Comp />
|
||||
return (
|
||||
<>
|
||||
<h1>Hello!</h1>
|
||||
<Comp />
|
||||
</>
|
||||
)
|
||||
}
|
||||
|
|
|
@ -5,6 +5,7 @@ import ClientComponent from './client-component'
|
|||
export default function Home() {
|
||||
return (
|
||||
<>
|
||||
<h1>Hello!</h1>
|
||||
<Comp />
|
||||
<ClientComponent />
|
||||
</>
|
||||
|
|
|
@ -2,5 +2,10 @@ import React from 'react'
|
|||
import Comp from '../../components/index.jsx'
|
||||
|
||||
export default function Home() {
|
||||
return <Comp />
|
||||
return (
|
||||
<>
|
||||
<h1>Hello!</h1>
|
||||
<Comp />
|
||||
</>
|
||||
)
|
||||
}
|
||||
|
|
|
@ -13,7 +13,7 @@ import prettyMs from 'pretty-ms'
|
|||
import treeKill from 'tree-kill'
|
||||
|
||||
const ROOT_DIR = join(fileURLToPath(import.meta.url), '..', '..', '..')
|
||||
const CWD = join(ROOT_DIR, 'bench', 'nested-deps')
|
||||
const CWD = join(ROOT_DIR, 'bench', 'nested-deps-app-router')
|
||||
|
||||
const NEXT_BIN = join(ROOT_DIR, 'packages', 'next', 'dist', 'bin', 'next')
|
||||
|
||||
|
@ -115,7 +115,7 @@ function runNextCommandDev(argv, opts = {}) {
|
|||
function handleStdout(data) {
|
||||
const message = data.toString()
|
||||
const bootupMarkers = {
|
||||
dev: /compiled .*successfully/i,
|
||||
dev: /Ready in .*/i,
|
||||
start: /started server/i,
|
||||
}
|
||||
if (
|
||||
|
@ -171,11 +171,16 @@ function waitFor(millis) {
|
|||
return new Promise((resolve) => setTimeout(resolve, millis))
|
||||
}
|
||||
|
||||
await fs.rm('.next', { recursive: true }).catch(() => {})
|
||||
const file = new File(join(CWD, 'pages/index.jsx'))
|
||||
const results = []
|
||||
for (const testCase of [
|
||||
'client-components-only',
|
||||
'server-and-client-components',
|
||||
'server-components-only',
|
||||
]) {
|
||||
await fs.rm('.next', { recursive: true }).catch(() => {})
|
||||
const file = new File(join(CWD, `app/${testCase}/page.js`))
|
||||
const results = []
|
||||
|
||||
try {
|
||||
try {
|
||||
if (command === 'dev' || command === 'all') {
|
||||
const instance = await runNextCommandDev(['dev', '--port', '3000'])
|
||||
|
||||
|
@ -184,11 +189,12 @@ try {
|
|||
function waitForOnData(data) {
|
||||
const message = data.toString()
|
||||
const compiledRegex =
|
||||
/compiled client and server successfully in (\d*[.]?\d+)\s*(m?s) \((\d+) modules\)/gm
|
||||
/Compiled (?:.+ )?in (\d*[.]?\d+)\s*(m?s)(?: \((\d+) modules\))?/gm
|
||||
const matched = compiledRegex.exec(message)
|
||||
if (matched) {
|
||||
resolve({
|
||||
'time (ms)': (matched[2] === 's' ? 1000 : 1) * Number(matched[1]),
|
||||
'time (ms)':
|
||||
(matched[2] === 's' ? 1000 : 1) * Number(matched[1]),
|
||||
modules: Number(matched[3]),
|
||||
})
|
||||
instance.stdout.removeListener('data', waitForOnData)
|
||||
|
@ -199,28 +205,30 @@ try {
|
|||
}
|
||||
|
||||
const [res, initial] = await Promise.all([
|
||||
fetch('http://localhost:3000/'),
|
||||
fetch(`http://localhost:3000/${testCase}`),
|
||||
waitForCompiled(),
|
||||
])
|
||||
if (res.status !== 200) {
|
||||
throw new Error('Fetching / failed')
|
||||
throw new Error(`Fetching /${testCase} failed`)
|
||||
}
|
||||
|
||||
results.push(initial)
|
||||
|
||||
file.prepend('// First edit')
|
||||
await waitFor(1000)
|
||||
|
||||
file.replace('Hello', 'Hello!')
|
||||
|
||||
results.push(await waitForCompiled())
|
||||
|
||||
await waitFor(1000)
|
||||
|
||||
file.prepend('// Second edit')
|
||||
file.replace('Hello', 'Hello!')
|
||||
|
||||
results.push(await waitForCompiled())
|
||||
|
||||
await waitFor(1000)
|
||||
|
||||
file.prepend('// Third edit')
|
||||
file.replace('Hello', 'Hello!')
|
||||
|
||||
results.push(await waitForCompiled())
|
||||
|
||||
|
@ -232,7 +240,7 @@ try {
|
|||
// ignore error
|
||||
await fs.rm('.next', { recursive: true, force: true }).catch(() => {})
|
||||
|
||||
execSync(`node ${NEXT_BIN} build ./bench/nested-deps`, {
|
||||
execSync(`node ${NEXT_BIN} build ./bench/nested-deps-app-router`, {
|
||||
cwd: ROOT_DIR,
|
||||
stdio: 'inherit',
|
||||
env: {
|
||||
|
@ -245,9 +253,12 @@ try {
|
|||
.split('\n')
|
||||
.filter((line) => line)
|
||||
.map((line) => JSON.parse(line))
|
||||
const { duration } = traces.pop().find(({ name }) => name === 'next-build')
|
||||
const { duration } = traces
|
||||
.pop()
|
||||
.find(({ name }) => name === 'next-build')
|
||||
console.info('next build duration: ', prettyMs(duration / 1000))
|
||||
}
|
||||
} finally {
|
||||
} finally {
|
||||
file.restore()
|
||||
}
|
||||
}
|
||||
|
|
|
@ -115,7 +115,7 @@ function runNextCommandDev(argv, opts = {}) {
|
|||
function handleStdout(data) {
|
||||
const message = data.toString()
|
||||
const bootupMarkers = {
|
||||
dev: /compiled .*successfully/i,
|
||||
dev: /Ready in .*/i,
|
||||
start: /started server/i,
|
||||
}
|
||||
if (
|
||||
|
@ -184,7 +184,7 @@ try {
|
|||
function waitForOnData(data) {
|
||||
const message = data.toString()
|
||||
const compiledRegex =
|
||||
/compiled client and server successfully in (\d*[.]?\d+)\s*(m?s) \((\d+) modules\)/gm
|
||||
/Compiled (?:.+ )?in (\d*[.]?\d+)\s*(m?s)(?: \((\d+) modules\))?/gm
|
||||
const matched = compiledRegex.exec(message)
|
||||
if (matched) {
|
||||
resolve({
|
||||
|
@ -208,19 +208,19 @@ try {
|
|||
|
||||
results.push(initial)
|
||||
|
||||
file.prepend('// First edit')
|
||||
file.replace('Hello', 'Hello!')
|
||||
|
||||
results.push(await waitForCompiled())
|
||||
|
||||
await waitFor(1000)
|
||||
|
||||
file.prepend('// Second edit')
|
||||
file.replace('Hello', 'Hello!')
|
||||
|
||||
results.push(await waitForCompiled())
|
||||
|
||||
await waitFor(1000)
|
||||
|
||||
file.prepend('// Third edit')
|
||||
file.replace('Hello', 'Hello!')
|
||||
|
||||
results.push(await waitForCompiled())
|
||||
|
||||
|
|
|
@ -1,5 +1,10 @@
|
|||
import Comp from '../components/index.jsx'
|
||||
|
||||
export default function Home() {
|
||||
return <Comp />
|
||||
return (
|
||||
<>
|
||||
<h1>Hello!</h1>
|
||||
<Comp />
|
||||
</>
|
||||
)
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue