Skip to content

Commit 184d171

Browse files
coderbirjuturan18
authored andcommitted
Add benchmark visualization workflow
This commit changes the benchmark.yml workflow into benchmark_visualization.yml. The new workflow runs on every code merge, it will run the benchmark target and upload the result as benchmark-result-artifact. The results are then converted to the appropriate format for visualization using the visualization_data_converter.sh shell script. It then uploads the newly generated data files to Github-pages using the github-action-benchmark action. Signed-off-by: Arjun Raja Yogidas <[email protected]>
1 parent 14b04a8 commit 184d171

File tree

1 file changed

+85
-17
lines changed

1 file changed

+85
-17
lines changed
Lines changed: 85 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
name: Benchmark
1+
name: Visualize Benchmark and upload results
22

33
on:
44
push:
@@ -7,28 +7,96 @@ on:
77
- '**'
88
- '!docs/**' # ignore docs changes
99
- '!**.md' # ignore markdown changes
10-
pull_request:
11-
branches: [ main ]
12-
paths:
13-
- '**.go'
14-
- 'go.*'
15-
- 'cmd/go.*'
16-
- 'Makefile'
17-
- 'Dockerfile'
18-
- 'integration/**'
19-
- 'scripts/**'
20-
10+
11+
permissions:
12+
contents: write
13+
deployments: write
14+
2115
jobs:
2216
benchmark:
23-
name: Performance regression check
2417
runs-on: ubuntu-20.04
2518
steps:
26-
- uses: actions/checkout@v3
19+
- name: Checkout main branch
20+
uses: actions/checkout@v3
21+
with:
22+
fetch-depth: 0
23+
submodules: true
2724
- uses: actions/setup-go@v4
2825
with:
2926
go-version: '1.20.6'
3027
- run: make
3128
- name: Run benchmark
32-
run: make benchmarks-perf-test
33-
- run: cd benchmark/performanceTest && cat output/results.json
34-
29+
run: make benchmarks-perf-test
30+
- name: Upload latest benchmark result
31+
uses: actions/upload-artifact@v3
32+
with:
33+
name: benchmark-result-artifact
34+
path: ${{github.workspace}}/benchmark/performanceTest/output/results.json
35+
36+
download-and-convert-benchmark-result-to-visualization-data:
37+
runs-on: ubuntu-20.04
38+
needs: benchmark
39+
steps:
40+
- name: Checkout main branch
41+
uses: actions/checkout@v3
42+
- name: Download latest benchmark result
43+
uses: actions/download-artifact@v3
44+
with:
45+
name: benchmark-result-artifact
46+
path: ${{github.workspace}}
47+
- name: Make temporary folder
48+
run: mkdir ${{github.workspace}}/current
49+
- name: Change permission of visualization_data_converter.sh
50+
run: chmod +x ${{github.workspace}}/scripts/visualization_data_converter.sh
51+
- name: Convert benchmark result to visualization data
52+
run: ${{github.workspace}}/scripts/visualization_data_converter.sh ${{github.workspace}}/results.json ${{github.workspace}}/current
53+
- name: Build matrix of filepaths
54+
id: set-matrix
55+
# Create a JSON array with the file paths and store it in the 'files' output
56+
run: echo "files=$(find ${{github.workspace}}/current -type f -name '*.json' -printf '%p\n' | jq -R . | jq -cs .)" >> $GITHUB_OUTPUT
57+
- name: Upload visualization files as github artifacts
58+
uses: actions/upload-artifact@v3
59+
with:
60+
name: benchmark-gh-pages-artifact
61+
path: ${{github.workspace}}/current
62+
outputs:
63+
matrix: ${{ steps.set-matrix.outputs.files }}
64+
65+
push-benchmark-result-gh-pages:
66+
name: Push benchmark result to Github-pages
67+
runs-on: ubuntu-20.04
68+
needs: download-and-convert-benchmark-result-to-visualization-data
69+
strategy:
70+
matrix:
71+
file: ${{ fromJson(needs.download-and-convert-benchmark-result-to-visualization-data.outputs.matrix) }}
72+
steps:
73+
- name: Checkout main branch
74+
uses: actions/checkout@v3
75+
76+
- name: Create current folder
77+
run: mkdir ${{github.workspace}}/current
78+
79+
- name: Download latest benchmark visualization files
80+
uses: actions/download-artifact@v3
81+
with:
82+
name: benchmark-gh-pages-artifact
83+
path: ${{github.workspace}}/current
84+
85+
- name: Extract file names
86+
id: get_filename
87+
run: |
88+
# Get the filename without the path
89+
filename=$(basename "${{ matrix.file }}")
90+
# Remove the .json extension
91+
filename_without_extension="${filename%.json}"
92+
echo "filename=$filename_without_extension" >> $GITHUB_OUTPUT
93+
94+
- name: Run benchmark action
95+
uses: benchmark-action/github-action-benchmark@v1
96+
with:
97+
name: Soci Benchmark
98+
tool: 'customSmallerIsBetter'
99+
benchmark-data-dir-path: "dev/benchmarks/performanceTest/${{ steps.get_filename.outputs.filename }}"
100+
output-file-path: ${{ matrix.file }}
101+
github-token: ${{ secrets.GITHUB_TOKEN }}
102+
auto-push: true

0 commit comments

Comments
 (0)