diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 3cff50e60..d8ac390a1 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -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 @@ -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}`; diff --git a/benchmark/src/run.ts b/benchmark/src/run.ts index c632efe39..22e4ec70c 100644 --- a/benchmark/src/run.ts +++ b/benchmark/src/run.ts @@ -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(); @@ -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); }