Skip to content

Commit dae7aba

Browse files
authored
Get benchmark data to visualizer (#878)
* Try zlibbing output data * Try with lz-string * Explicitly install lz-string * Another try with regular zlib * Use deflateSync now * Try without extra dependencies * Once more, with dollarsign * Output raw results instead of processed table * Fix run script * reverted package-lock * Add link to visualizer to benchmark result * prettier fix * Removed forgotten comment from benchmarking CI
1 parent ea748a3 commit dae7aba

File tree

2 files changed

+12
-9
lines changed

2 files changed

+12
-9
lines changed

.github/workflows/ci.yml

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -61,8 +61,7 @@ jobs:
6161
node-version: 12.13.1
6262
# NPM
6363
- 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
64+
run: npm ci && npm run build
6665
working-directory: master
6766
- name: NPM commit
6867
run: npm ci && npm run build
@@ -112,7 +111,12 @@ jobs:
112111
const benchmarkInfoLua = JSON.parse(core.getInput('benchmark-info-lua', { required: true }));
113112
const benchmarkInfoJIT = JSON.parse(core.getInput('benchmark-info-jit', { required: true }));
114113
115-
const summary = `### Lua5.3\n${benchmarkInfoLua.summary}\n### LuaJIT\n${benchmarkInfoJIT.summary}`;
114+
const zlib = require('zlib');
115+
const buffer = Buffer.from(core.getInput('benchmark-info-lua', { required: true }));
116+
const compressed = zlib.deflateSync(buffer);
117+
118+
const summary = `[Open visualizer](https://typescripttolua.github.io/benchviz?d=${compressed.toString('base64')})\n`
119+
+ `### Lua5.3\n${benchmarkInfoLua.summary}\n### LuaJIT\n${benchmarkInfoJIT.summary}`;
116120
117121
const text = `### Lua5.3\n${benchmarkInfoLua.text}\n### LuaJIT\n${benchmarkInfoJIT.text}`;
118122

benchmark/src/run.ts

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -27,11 +27,8 @@ function benchmark(): void {
2727
oldBenchmarkResults = json.decode(oldBenchmarkData) as BenchmarkResult[];
2828
}
2929

30-
// Compare results
31-
const comparisonInfo = compareBenchmarks(oldBenchmarkResults, newBenchmarkResults);
32-
3330
// Output comparison info
34-
outputBenchmarkData(comparisonInfo, newBenchmarkResults);
31+
outputBenchmarkData(oldBenchmarkResults, newBenchmarkResults);
3532
}
3633
benchmark();
3734

@@ -44,12 +41,14 @@ function compareBenchmarks(oldResults: BenchmarkResult[], newResults: BenchmarkR
4441
return { summary: memoryComparisonInfo.summary, text: memoryComparisonInfo.text };
4542
}
4643

47-
function outputBenchmarkData(comparisonInfo: { summary: string; text: string }, newResults: BenchmarkResult[]): void {
44+
function outputBenchmarkData(oldResults: BenchmarkResult[], newResults: BenchmarkResult[]): void {
4845
if (!arg[2]) {
4946
// Output to stdout as json by default, this is used by the CI to retrieve the info
50-
print(json.encode(comparisonInfo));
47+
print(json.encode({ old: oldResults, new: newResults }));
5148
} else {
5249
// Output to file as markdown if arg[2] is set, this is useful for local development
50+
// Compare results
51+
const comparisonInfo = compareBenchmarks(oldResults, newResults);
5352
const markdownDataFile = io.open(arg[2], "w+")[0]!;
5453
markdownDataFile.write(comparisonInfo.summary + comparisonInfo.text);
5554
}

0 commit comments

Comments
 (0)