Skip to content
Merged
10 changes: 7 additions & 3 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -61,8 +61,7 @@ jobs:
node-version: 12.13.1
# NPM
- name: NPM master
# TODO Lua types is only added manually to test the benchmark PR this can be removed again once the PR is merged
run: npm ci && npm run build && npm install -D lua-types
run: npm ci && npm run build
working-directory: master
- name: NPM commit
run: npm ci && npm run build
Expand Down Expand Up @@ -112,7 +111,12 @@ jobs:
const benchmarkInfoLua = JSON.parse(core.getInput('benchmark-info-lua', { required: true }));
const benchmarkInfoJIT = JSON.parse(core.getInput('benchmark-info-jit', { required: true }));

const summary = `### Lua5.3\n${benchmarkInfoLua.summary}\n### LuaJIT\n${benchmarkInfoJIT.summary}`;
const zlib = require('zlib');
const buffer = Buffer.from(core.getInput('benchmark-info-lua', { required: true }));
const compressed = zlib.deflateSync(buffer);

const summary = `[Open visualizer](https://typescripttolua.github.io/benchviz?d=${compressed.toString('base64')})\n`
+ `### Lua5.3\n${benchmarkInfoLua.summary}\n### LuaJIT\n${benchmarkInfoJIT.summary}`;

const text = `### Lua5.3\n${benchmarkInfoLua.text}\n### LuaJIT\n${benchmarkInfoJIT.text}`;

Expand Down
11 changes: 5 additions & 6 deletions benchmark/src/run.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,11 +27,8 @@ function benchmark(): void {
oldBenchmarkResults = json.decode(oldBenchmarkData) as BenchmarkResult[];
}

// Compare results
const comparisonInfo = compareBenchmarks(oldBenchmarkResults, newBenchmarkResults);

// Output comparison info
outputBenchmarkData(comparisonInfo, newBenchmarkResults);
outputBenchmarkData(oldBenchmarkResults, newBenchmarkResults);
}
benchmark();

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

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