Skip to content

Commit 6c5d8db

Browse files
authored
Separate benchmarks for comparison from common bechmarks (#150)
1 parent 13ab8df commit 6c5d8db

File tree

2 files changed

+35
-8
lines changed

2 files changed

+35
-8
lines changed

.github/workflows/benchmark.yml

Lines changed: 28 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ jobs:
5050
matrix:
5151
include:
5252
- os: ubuntu-latest
53-
additional-task: ''
53+
additional-task: ':benchmark:jvmComparisonBenchmark'
5454
- os: macos-latest
5555
additional-task: '-x :benchmark:jvmBenchmark'
5656
- os: macos-13 # for macosX64
@@ -59,6 +59,8 @@ jobs:
5959
additional-task: '-x :benchmark:jvmBenchmark'
6060
runs-on: ${{ matrix.os }}
6161
name: Run benchmarks on ${{ matrix.os }}
62+
env:
63+
BENCHMARK_RESULTS: 'benchmark/build/reports/benchmarks'
6264
steps:
6365
- name: 'Install native dependencies'
6466
run: sudo apt-get install -y libunistring-dev
@@ -107,7 +109,7 @@ jobs:
107109
shell: bash
108110
if: env.REPORT_FORMAT == 'csv'
109111
run: |
110-
for report in $(find ./benchmark/build/reports/benchmarks/main -type f -name "*.csv")
112+
for report in $(find ./${{ env.BENCHMARK_RESULTS }} -type f -name "*.csv")
111113
do
112114
file_name=$(basename "$report")
113115
platform="${file_name%.*}"
@@ -129,7 +131,13 @@ jobs:
129131
uses: actions/upload-artifact@v4
130132
with:
131133
name: bench-result-${{ matrix.os }}
132-
path: benchmark/build/reports/benchmarks/main/**/*.json
134+
path: ${{ env.BENCHMARK_RESULTS }}/main/**/*.json
135+
- name: Store comparison results as artifact
136+
if: env.REPORT_FORMAT == 'json' && matrix.os == 'ubuntu-latest'
137+
uses: actions/upload-artifact@v4
138+
with:
139+
name: bench-comparison-result-${{ matrix.os }}
140+
path: ${{ env.BENCHMARK_RESULTS }}/comparison/**/*.json
133141

134142
upload-benchmark-results:
135143
if: (github.event_name == 'push' || github.event_name == 'pull_request') && github.repository == 'OptimumCode/json-schema-validator'
@@ -145,12 +153,25 @@ jobs:
145153
contents: write
146154
# pull-requests permission to create comments on PR in case of alert
147155
pull-requests: write
156+
strategy:
157+
# to make sure results are submitted one by one
158+
max-parallel: 1
159+
matrix:
160+
include:
161+
- artifact-pattern: 'bench-result-*'
162+
results-name: KMP JSON schema validator
163+
alert: true
164+
- artifact-pattern: 'bench-comparison-result-*'
165+
results-name: Compare KMP JSON schema validator
166+
alert: false
167+
name: 'Process benchmark results for ${{ matrix.results-name }}'
148168
steps:
149169
- name: 'Checkout Repository'
150170
uses: actions/checkout@v4
151171
- name: Download benchmark results
152172
uses: actions/download-artifact@v4
153173
with:
174+
pattern: ${{ matrix.artifact-pattern }}
154175
path: ${{ env.RESULTS_DIR }}
155176
merge-multiple: true
156177
- name: Show downloaded artifacts
@@ -173,14 +194,14 @@ jobs:
173194
- name: Store benchmark result
174195
uses: benchmark-action/github-action-benchmark@v1
175196
with:
176-
name: KMP JSON schema validator
197+
name: ${{ matrix.results-name }}
177198
tool: 'jmh'
178199
output-file-path: ${{ steps.prep.outputs.report }}
179200
alert-comment-cc-users: "@OptimumCode"
180-
comment-on-alert: true
201+
comment-on-alert: ${{ matrix.alert }}
181202
summary-always: true
182-
alert-threshold: '50%'
183-
fail-threshold: '100%'
203+
alert-threshold: '150%'
204+
fail-threshold: '200%'
184205
max-items-in-chart: 50
185206
github-token: ${{ secrets.GITHUB_TOKEN }}
186207
# Push and deploy GitHub pages branch automatically only if run in main repo and not in PR

benchmark/build.gradle.kts

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ fun Any?.takeIfNotBlank(): String? = this?.toString()?.takeUnless(String::isBlan
5050

5151
benchmark {
5252
configurations {
53-
getByName("main") {
53+
configureEach {
5454
warmups = properties["benchmark_warmups"]?.takeIfNotBlank()?.toInt() ?: 5
5555
iterations = properties["benchmark_iterations"]?.takeIfNotBlank()?.toInt() ?: 10
5656
iterationTime = properties["benchmark_iteration_time"]?.takeIfNotBlank()?.toLong() ?: 1L
@@ -59,6 +59,12 @@ benchmark {
5959
param("objectPath", "$projectDir/data/openapi.json", "$projectDir/data/openapi-invalid.json")
6060
param("schemaPath", "$projectDir/data/schemas/openapi_schema.json")
6161
}
62+
getByName("main") {
63+
include(".*Common.*Bench.*")
64+
}
65+
create("comparison") {
66+
include(".*Comparison.*Benchmark.*")
67+
}
6268
}
6369
targets {
6470
register("jvm")

0 commit comments

Comments
 (0)