-
Notifications
You must be signed in to change notification settings - Fork 190
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
setup-bench script + add alias + + + + + lintfix +
- Loading branch information
Showing
7 changed files
with
2,965 additions
and
204 deletions.
There are no files selected for viewing
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 |
---|---|---|
@@ -0,0 +1,107 @@ | ||
import 'zx/globals'; | ||
import os from 'node:os'; | ||
import { join } from 'node:path'; | ||
|
||
/* | ||
To run proper bench setup we need to do following things: | ||
1.) Compile control packages | ||
2.) Compile experiment packages | ||
3.) Use SAME benchmark source | ||
* we should be able to tweak bench | ||
(add more cases, and still be able to compare with control) | ||
* we should be able to re-run bench in CI from current branch with updated perf source | ||
*/ | ||
|
||
const experimentBranchName = | ||
process.env['EXPERIMENT_BRANCH_NAME'] || 'attempt-to-get-perf-testing-work'; | ||
const controlBranchName = process.env['CONTROL_BRANCH_NAME'] || 'main'; | ||
const markers = process.env['MARKERS'] || 'glimmer-render-1000-rows,glimmer-render-1000-rows-finished'; | ||
const fidelity = process.env['FIDELITY'] || '20'; | ||
const throttleRate = process.env['THROTTLE'] || '4'; | ||
|
||
const tempDir = os.tmpdir(); | ||
|
||
const CONTROL_DIR = join(tempDir, 'control'); | ||
const EXPERIMENT_DIR = join(tempDir, 'experiment'); | ||
|
||
const CONTROL_BENCH_DIR = join(CONTROL_DIR, 'benchmark', 'benchmarks', 'krausest'); | ||
const EXPERIMENT_BENCH_DIR = join(EXPERIMENT_DIR, 'benchmark', 'benchmarks', 'krausest'); | ||
|
||
const pwdRaw = await $`pwd`; | ||
const pwd = pwdRaw.toString().trim(); | ||
|
||
// we use benchmark from current commit, very useful if we need to tweak it | ||
const benchmarkFolder = 'benchmark'; | ||
|
||
// remove node_modules from benchmark folder, maybe we could figure out better option to distribute bench source | ||
await $`rm -rf ${join(pwd, benchmarkFolder, 'node_modules')}`; | ||
await $`rm -rf ${join(pwd, benchmarkFolder, 'benchmarks', 'krausest', 'node_modules')}`; | ||
|
||
await $`rm -rf ${CONTROL_DIR}`; | ||
await $`rm -rf ${EXPERIMENT_DIR}`; | ||
await $`mkdir ${CONTROL_DIR}`; | ||
await $`mkdir ${EXPERIMENT_DIR}`; | ||
|
||
const BENCHMARK_FOLDER = join(pwd, benchmarkFolder); | ||
|
||
const rawUpstreamUrl = await $`git ls-remote --get-url upstream`; | ||
const rawOriginUrl = await $`git ls-remote --get-url origin`; | ||
const originUrlStr = rawOriginUrl.toString().trim(); | ||
const upstreamUrlStr = rawUpstreamUrl.toString().trim(); | ||
const CONTROL_PORT = 4020; | ||
const EXPERIMENT_PORT = 4021; | ||
const CONTROL_URL = `http://localhost:${CONTROL_PORT}`; | ||
const EXPERIMENT_URL = `http://localhost:${EXPERIMENT_PORT}`; | ||
// const MARKERS = ['glimmer-render-1000-rows', 'glimmer-render-1000-rows-finished']; | ||
|
||
await Promise.all([ | ||
$`cd ${CONTROL_DIR} && git clone ${upstreamUrlStr} . && git checkout ${controlBranchName} && rm -rf benchmark && cp -r ${BENCHMARK_FOLDER} ./benchmark && pnpm install && pnpm build`, | ||
$`cd ${EXPERIMENT_DIR} && git clone ${originUrlStr} . && git checkout ${experimentBranchName} && rm -rf benchmark && cp -r ${BENCHMARK_FOLDER} ./benchmark && pnpm install && pnpm build`, | ||
]); | ||
|
||
// create vite production build | ||
// cd ${{ github.workspace }}/benchmark/benchmarks/krausest && pnpm vite --port 5000 | ||
|
||
// replace incorrect paths in package json | ||
|
||
// in control | ||
await $`cd ${CONTROL_DIR} && find ./packages -name 'package.json' -exec sed -i '' 's|"main": "index.ts",|"module": "./dist/prod/index.js","main": "./dist/prod/index.js",|g' {} \\;`; | ||
await $`cd ${CONTROL_DIR} && find ./packages -name 'package.json' -exec sed -i '' 's|"main": "./dist/index.js",|"module": "./dist/prod/index.js","main": "./dist/prod/index.js",|g' {} \\;`; | ||
await $`cd ${CONTROL_DIR} && find ./packages -name 'package.json' -exec sed -i '' 's|"import": "./dist/index.js"|"import": "./dist/prod/index.js"|g' {} \\;`; | ||
|
||
// in experiment | ||
await $`cd ${EXPERIMENT_DIR} && find ./packages -name 'package.json' -exec sed -i '' 's|"main": "index.ts",|"main": "./dist/prod/index.js","module": "./dist/prod/index.js",|g' {} \\;`; | ||
await $`cd ${EXPERIMENT_DIR} && find ./packages -name 'package.json' -exec sed -i '' 's|"main": "./dist/index.js",|"main": "./dist/prod/index.js","module": "./dist/prod/index.js",|g' {} \\;`; | ||
await $`cd ${EXPERIMENT_DIR} && find ./packages -name 'package.json' -exec sed -i '' 's|"import": "./dist/index.js"|"import": "./dist/prod/index.js"|g' {} \\;`; | ||
|
||
// build control and experiment | ||
await Promise.all([ | ||
$`cd ${CONTROL_BENCH_DIR} && pnpm vite build`, | ||
$`cd ${EXPERIMENT_BENCH_DIR} && pnpm vite build`, | ||
]).catch((e) => { | ||
console.log({ | ||
upstreamUrlStr, | ||
originUrlStr, | ||
EXPERIMENT_DIR, | ||
CONTROL_DIR, | ||
}); | ||
throw e; | ||
}); | ||
|
||
// start build assets | ||
Promise.all([ | ||
$`cd ${CONTROL_BENCH_DIR} && pnpm vite preview --port ${CONTROL_PORT}`, | ||
$`cd ${EXPERIMENT_BENCH_DIR} && pnpm vite preview --port ${EXPERIMENT_PORT}`, | ||
]); | ||
|
||
await new Promise((resolve) => { | ||
// giving 5 seconds for the server to start | ||
setTimeout(resolve, 5000); | ||
}); | ||
|
||
await $`./node_modules/.bin/tracerbench compare --fidelity ${fidelity} --markers ${markers} --controlURL ${CONTROL_URL} --experimentURL ${EXPERIMENT_URL} --report --headless --cpuThrottleRate ${throttleRate}`; | ||
|
||
process.exit(0); |
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.