Skip to content

Commit 6488a35

Browse files
authored
Add public benchmarks, starting with vscode and self tests (#5)
1 parent 3089bfc commit 6488a35

14 files changed

Lines changed: 192 additions & 25 deletions

File tree

README.md

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,22 @@
33
This repo contains the infrastructure for TypeScript's benchmarking system, including build scripts
44
and the `ts-perf` CLI tool.
55

6+
## Adding a benchmark
7+
8+
Public benchmarks are stored in the `cases` directory.
9+
10+
The simplest thing to do is to copy another benchmark; `cases/scenarios/vscode` is a good template.
11+
12+
Each benchmark consists of:
13+
14+
- `cases/scenarios/<name>/scenario.json` - This is JSON file which describes what `ts-perf` will run.
15+
- `cases/scenarios/<name>/setup.sh` - This is an optional script that CI will run before benchmarking for setting up the benchmark.
16+
This is where you would clone repos, install dependencies, etc, whatever is needed to run `tsc`.
17+
- `cases/solutions/<name>` (or an ignored dir of the same name in `cases/solutions/.gitignore`) - This is where the source code for the benchmark is stored.
18+
This may be code that's checked in the repo, but preferably the directory is `.gitignore`'d and `setup.sh` script clones code here.
19+
20+
After these files are created, they must be added to `scenarioConfig` in `scripts/src/generateMatrix.ts` to be run in CI.
21+
622
## Contributing
723

824
This project welcomes contributions and suggestions. Most contributions require you to agree to a

build/benchmark.yml

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,7 @@ parameters:
6363
- tsc-only
6464
- bun
6565
- vscode
66+
- public
6667
default: full # Branch pushes use the defaults, so this is set to full.
6768

6869
- name: HISTORICAL_RUN
@@ -148,6 +149,7 @@ jobs:
148149
displayName: Build PR TypeScript
149150
condition: and(succeeded(), eq(variables['IS_PR'], 'true'))
150151
workingDirectory: $(Pipeline.Workspace)/TypeScript
152+
name: buildTypeScriptPR
151153
152154
- bash: |
153155
set -eo pipefail
@@ -161,6 +163,7 @@ jobs:
161163
node $(BENCH_SCRIPTS)/buildTypeScript.js --baseline --outputDir $(ARTIFACTS_DIR)/baseline
162164
displayName: Build baseline TypeScript
163165
workingDirectory: $(Pipeline.Workspace)/TypeScript
166+
name: buildTypeScriptBaseline
164167
165168
- publish: $(ARTIFACTS_DIR)
166169
artifact: BuiltTypeScript
@@ -184,6 +187,8 @@ jobs:
184187
variables:
185188
BUILT_TYPESCRIPT_DIR: $(Pipeline.Workspace)/BuiltTypeScript
186189
ARTIFACTS_DIR: $(Pipeline.Workspace)/artifacts
190+
TYPESCRIPT_COMMIT_PR: $[ dependencies.Setup.outputs['buildTypeScriptPR.TYPESCRIPT_COMMIT'] ]
191+
TYPESCRIPT_COMMIT_BASELINE: $[ dependencies.Setup.outputs['buildTypeScriptBaseline.TYPESCRIPT_COMMIT'] ]
187192

188193
steps:
189194
- task: AzureKeyVault@2
@@ -214,6 +219,18 @@ jobs:
214219
node $(BENCH_SCRIPTS)/runTsPerf.js install-hosts
215220
displayName: Install hosts
216221
222+
- bash: |
223+
set -eo pipefail
224+
# Special case for self benchmark
225+
export TYPESCRIPT_COMMIT=$(TYPESCRIPT_COMMIT_PR)
226+
SETUP=$(TSPERF_PUBLIC_SCENARIO_CONFIG_DIR)/$(TSPERF_JOB_SCENARIO)/setup.sh
227+
if test -f $SETUP; then
228+
echo "Running $SETUP"
229+
bash $SETUP
230+
fi
231+
displayName: Set up scenario for PR benchmark
232+
condition: and(succeeded(), eq(variables['IS_PR'], 'true'), eq(variables['TSPERF_JOB_LOCATION'], 'public'))
233+
217234
- bash: |
218235
set -eo pipefail
219236
node $(BENCH_SCRIPTS)/runTsPerf.js benchmark-$(TSPERF_JOB_KIND) \
@@ -222,6 +239,18 @@ jobs:
222239
displayName: Run PR $(TSPERF_JOB_KIND) benchmark
223240
condition: and(succeeded(), eq(variables['IS_PR'], 'true'))
224241
242+
- bash: |
243+
set -eo pipefail
244+
# Special case for self benchmark
245+
export TYPESCRIPT_COMMIT=$(TYPESCRIPT_COMMIT_BASELINE)
246+
SETUP=$(TSPERF_PUBLIC_SCENARIO_CONFIG_DIR)/$(TSPERF_JOB_SCENARIO)/setup.sh
247+
if test -f $SETUP; then
248+
echo "Running $SETUP"
249+
bash $SETUP
250+
fi
251+
displayName: Set up scenario for baseline benchmark
252+
condition: and(succeeded(), eq(variables['TSPERF_JOB_LOCATION'], 'public'))
253+
225254
- bash: |
226255
set -eo pipefail
227256
node $(BENCH_SCRIPTS)/runTsPerf.js benchmark-$(TSPERF_JOB_KIND) \

build/templates/cloneAndBuildBenchmarkRepo.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,6 @@ steps:
2525
echo "##vso[task.setvariable variable=TSPERF_EXE]$(Pipeline.Workspace)/typescript-benchmarking/ts-perf/bin/ts-perf"
2626
2727
# TODO(jakebailey): actually create these dirs, move them to more reasonable names, clone external repos as needed
28-
echo "##vso[task.setvariable variable=TSPERF_PUBLIC_SCENARIO_CONFIG_DIR]$(Pipeline.Workspace)/typescript-benchmarking/cases/perf/scenarios"
29-
echo "##vso[task.setvariable variable=TSPERF_PUBLIC_SUITE_DIR]$(Pipeline.Workspace)/typescript-benchmarking/cases/perf/solutions"
28+
echo "##vso[task.setvariable variable=TSPERF_PUBLIC_SCENARIO_CONFIG_DIR]$(Pipeline.Workspace)/typescript-benchmarking/cases/scenarios"
29+
echo "##vso[task.setvariable variable=TSPERF_PUBLIC_SUITE_DIR]$(Pipeline.Workspace)/typescript-benchmarking/cases/solutions"
3030
displayName: Set typescript-benchmarking variables
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
{
2+
"name": "self-build-src",
3+
"kind": "tsc",
4+
"args": [
5+
"-b",
6+
"${suiteDirectory}/self-build-src/src"
7+
],
8+
"platforms": [
9+
"linux"
10+
]
11+
}
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
#!/usr/bin/env bash
2+
3+
set -exo pipefail
4+
5+
cd "${0%/*}"
6+
SCENARIO_NAME=$(basename $PWD)
7+
SOLUTION_DIR=../../solutions/$SCENARIO_NAME
8+
9+
if ! test -d $SOLUTION_DIR; then
10+
git clone --filter blob:none https://github.com/microsoft/TypeScript.git $SOLUTION_DIR
11+
fi
12+
13+
cd $SOLUTION_DIR
14+
git clean -fdx
15+
git reset --hard HEAD
16+
git fetch origin ${TYPESCRIPT_COMMIT}
17+
git switch --detach FETCH_HEAD
18+
npm ci
19+
npx hereby generate-diagnostics
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
{
2+
"name": "self-compiler",
3+
"kind": "tsc",
4+
"args": [
5+
"-p",
6+
"${suiteDirectory}/self-compiler/src/compiler",
7+
"--outdir",
8+
"${outDirectory}"
9+
],
10+
"platforms": [
11+
"linux"
12+
]
13+
}
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
#!/usr/bin/env bash
2+
3+
set -exo pipefail
4+
5+
cd "${0%/*}"
6+
SCENARIO_NAME=$(basename $PWD)
7+
SOLUTION_DIR=../../solutions/$SCENARIO_NAME
8+
9+
if ! test -d $SOLUTION_DIR; then
10+
git clone --filter blob:none https://github.com/microsoft/TypeScript.git $SOLUTION_DIR
11+
fi
12+
13+
cd $SOLUTION_DIR
14+
git clean -fdx
15+
git reset --hard HEAD
16+
git fetch origin ${TYPESCRIPT_COMMIT}
17+
git switch --detach FETCH_HEAD
18+
npm ci
19+
npx hereby generate-diagnostics
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
{
2+
"name": "vscode",
3+
"kind": "tsc",
4+
"args": [
5+
"-p",
6+
"${suiteDirectory}/vscode/src",
7+
"--outdir",
8+
"${outDirectory}"
9+
],
10+
"platforms": [
11+
"linux"
12+
]
13+
}

cases/scenarios/vscode/setup.sh

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
#!/usr/bin/env bash
2+
3+
set -exo pipefail
4+
5+
cd "${0%/*}"
6+
SCENARIO_NAME=$(basename $PWD)
7+
SOLUTION_DIR=../../solutions/$SCENARIO_NAME
8+
9+
if ! test -d $SOLUTION_DIR; then
10+
git clone --filter blob:none https://github.com/microsoft/vscode.git $SOLUTION_DIR
11+
fi
12+
13+
cd $SOLUTION_DIR
14+
git clean -fdx
15+
git reset --hard HEAD
16+
git switch --detach f88bce8fe6a6d2ccd27cbd64bb26853cd8779afa
17+
COREPACK_ENABLE_STRICT=0 corepack yarn@1.22.21 install --ignore-scripts

cases/solutions/.gitignore

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
/vscode/
2+
/self-compiler/
3+
/self-build-src/

0 commit comments

Comments
 (0)