Skip to content

Commit b62f733

Browse files
committed
Run benchmarks on master and commit
1 parent edc37d8 commit b62f733

File tree

2 files changed

+53
-30
lines changed

2 files changed

+53
-30
lines changed

.github/workflows/ci.yml

Lines changed: 51 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -45,43 +45,69 @@ jobs:
4545
steps:
4646
- name: Lua Install
4747
run: sudo apt-get install lua5.3 luajit
48-
- uses: actions/checkout@v2
48+
# Checkout master & commit
49+
- name: Checkout master
50+
uses: actions/checkout@v2
51+
with:
52+
ref: master
53+
path: master
54+
- name: Checkout commit
55+
uses: actions/checkout@v2
56+
with:
57+
path: commit
4958
- name: Use Node.js 12.13.1
5059
uses: actions/setup-node@v1
5160
with:
5261
node-version: 12.13.1
53-
- run: npm ci
54-
- run: npm run build
55-
# This will never result in a direct cache hit.
56-
# Teherefore benchmark data is always updated.
57-
- name: Cache benchmark data
58-
id: cache-benchmark
59-
uses: actions/cache@v1
60-
with:
61-
path: ./benchmark/data
62-
key: ${{ runner.os }}-master-benchmark-${{ github.sha }}
63-
restore-keys: ${{ runner.os }}-master-benchmark-
62+
# NPM
63+
- name: NPM master
64+
# TODO Lua types is only added manually to test the benchmark PR this can be removed again once the PR is merged
65+
run: npm ci && npm run build && npm install -D lua-types
66+
working-directory: master
67+
- name: NPM commit
68+
- run: npm ci && npm run build
69+
working-directory: commit
70+
# Benchmark estup
6471
- name: Ensure benchmark data dir exists
6572
run: mkdir -p ./benchmark/data
66-
- name: Build benchmark Lua 5.3
73+
working-directory: commit
74+
- name: Copy commit benchmark to master
75+
run: rm -rf ./master/benchmark && cp -rf ./commit/benchmark ./master/benchmark
76+
# Run master benchmark first and output to commit benchmark data
77+
- name: Build benchmark Lua 5.3 master
78+
run: node ../dist/tstl.js -p tsconfig.53.json
79+
working-directory: master/benchmark
80+
- name: Run benchmark Lua 5.3 master
81+
id: benchmark-lua-master
82+
run: lua5.3 -- run.lua ../../../commit/benchmark/data/benchmark_53.json
83+
working-directory: master/benchmark/dist
84+
- name: Build benchmark LuaJIT master
85+
run: node ../dist/tstl.js -p tsconfig.jit.json
86+
working-directory: master/benchmark
87+
- name: Run benchmark LuaJIT
88+
id: benchmark-jit-master
89+
run: luajit -- run.lua ../../../commit/benchmark/data/benchmark_jit.json
90+
working-directory: master/benchmark/dist
91+
# Run commit benchmark and compare with master
92+
- name: Build benchmark Lua 5.3 commit
6793
run: node ../dist/tstl.js -p tsconfig.53.json
68-
working-directory: benchmark
69-
- name: Run benchmark Lua 5.3
70-
id: benchmark-lua
71-
run: echo ::set-output name=info::`lua5.3 -- run.lua ../data/benchmark_master_53.json ${{github.ref}}`
72-
working-directory: benchmark/dist
73-
- name: Build benchmark LuaJIT
94+
working-directory: commit/benchmark
95+
- name: Run benchmark Lua 5.3 commit
96+
id: benchmark-lua-commit
97+
run: echo ::set-output name=info::`lua5.3 -- run.lua ../data/benchmark_53.json`
98+
working-directory: commit/benchmark/dist
99+
- name: Build benchmark LuaJIT commit
74100
run: node ../dist/tstl.js -p tsconfig.jit.json
75-
working-directory: benchmark
101+
working-directory: commit/benchmark
76102
- name: Run benchmark LuaJIT
77-
id: benchmark-jit
78-
run: echo ::set-output name=info::`luajit -- run.lua ../data/benchmark_master_jit.json ${{github.ref}}`
79-
working-directory: benchmark/dist
103+
id: benchmark-jit-commit
104+
run: echo ::set-output name=info::`luajit -- run.lua ../data/benchmark_jit.json`
105+
working-directory: commit/benchmark/dist
80106
- name: Create benchmark check
81107
uses: actions/github-script@0.9.0
82108
with:
83-
benchmark-info-lua: ${{steps.benchmark-lua.outputs.info}}
84-
benchmark-info-jit: ${{steps.benchmark-jit.outputs.info}}
109+
benchmark-info-lua: ${{steps.benchmark-lua-commit.outputs.info}}
110+
benchmark-info-jit: ${{steps.benchmark-jit-commit.outputs.info}}
85111
script: |
86112
const benchmarkInfoLua = JSON.parse(core.getInput('benchmark-info-lua', { required: true }));
87113
const benchmarkInfoJIT = JSON.parse(core.getInput('benchmark-info-jit', { required: true }));

benchmark/run.ts

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -37,11 +37,8 @@ function benchmark() {
3737
print(json.encode({ summary: "new benchmark (no results yet)", text: "" }));
3838
}
3939

40-
// Only update baseline if we are on master branch
41-
if (arg[1] && string.find(arg[1], "master")[0]) {
42-
const updatedMasterFile = io.open(arg[0], "w+")[0] as LuaFile;
43-
updatedMasterFile.write(json.encode(updatedResults));
44-
}
40+
const updatedMasterFile = io.open(arg[0], "w+")[0] as LuaFile;
41+
updatedMasterFile.write(json.encode(updatedResults));
4542
}
4643
benchmark();
4744

0 commit comments

Comments
 (0)