Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Separate benchmarks for comparison from common bechmarks #150

Merged
merged 6 commits into from
Jul 2, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
35 changes: 28 additions & 7 deletions .github/workflows/benchmark.yml
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ jobs:
matrix:
include:
- os: ubuntu-latest
additional-task: ''
additional-task: ':benchmark:jvmComparisonBenchmark'
- os: macos-latest
additional-task: '-x :benchmark:jvmBenchmark'
- os: macos-13 # for macosX64
Expand All @@ -59,6 +59,8 @@ jobs:
additional-task: '-x :benchmark:jvmBenchmark'
runs-on: ${{ matrix.os }}
name: Run benchmarks on ${{ matrix.os }}
env:
BENCHMARK_RESULTS: 'benchmark/build/reports/benchmarks'
steps:
- name: 'Install native dependencies'
run: sudo apt-get install -y libunistring-dev
Expand Down Expand Up @@ -107,7 +109,7 @@ jobs:
shell: bash
if: env.REPORT_FORMAT == 'csv'
run: |
for report in $(find ./benchmark/build/reports/benchmarks/main -type f -name "*.csv")
for report in $(find ./${{ env.BENCHMARK_RESULTS }} -type f -name "*.csv")
do
file_name=$(basename "$report")
platform="${file_name%.*}"
Expand All @@ -129,7 +131,13 @@ jobs:
uses: actions/upload-artifact@v4
with:
name: bench-result-${{ matrix.os }}
path: benchmark/build/reports/benchmarks/main/**/*.json
path: ${{ env.BENCHMARK_RESULTS }}/main/**/*.json
- name: Store comparison results as artifact
if: env.REPORT_FORMAT == 'json' && matrix.os == 'ubuntu-latest'
uses: actions/upload-artifact@v4
with:
name: bench-comparison-result-${{ matrix.os }}
path: ${{ env.BENCHMARK_RESULTS }}/comparison/**/*.json

upload-benchmark-results:
if: (github.event_name == 'push' || github.event_name == 'pull_request') && github.repository == 'OptimumCode/json-schema-validator'
Expand All @@ -145,12 +153,25 @@ jobs:
contents: write
# pull-requests permission to create comments on PR in case of alert
pull-requests: write
strategy:
# to make sure results are submitted one by one
max-parallel: 1
matrix:
include:
- artifact-pattern: 'bench-result-*'
results-name: KMP JSON schema validator
alert: true
- artifact-pattern: 'bench-comparison-result-*'
results-name: Compare KMP JSON schema validator
alert: false
name: 'Process benchmark results for ${{ matrix.results-name }}'
steps:
- name: 'Checkout Repository'
uses: actions/checkout@v4
- name: Download benchmark results
uses: actions/download-artifact@v4
with:
pattern: ${{ matrix.artifact-pattern }}
path: ${{ env.RESULTS_DIR }}
merge-multiple: true
- name: Show downloaded artifacts
Expand All @@ -173,14 +194,14 @@ jobs:
- name: Store benchmark result
uses: benchmark-action/github-action-benchmark@v1
with:
name: KMP JSON schema validator
name: ${{ matrix.results-name }}
tool: 'jmh'
output-file-path: ${{ steps.prep.outputs.report }}
alert-comment-cc-users: "@OptimumCode"
comment-on-alert: true
comment-on-alert: ${{ matrix.alert }}
summary-always: true
alert-threshold: '50%'
fail-threshold: '100%'
alert-threshold: '150%'
fail-threshold: '200%'
max-items-in-chart: 50
github-token: ${{ secrets.GITHUB_TOKEN }}
# Push and deploy GitHub pages branch automatically only if run in main repo and not in PR
Expand Down
8 changes: 7 additions & 1 deletion benchmark/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ fun Any?.takeIfNotBlank(): String? = this?.toString()?.takeUnless(String::isBlan

benchmark {
configurations {
getByName("main") {
configureEach {
warmups = properties["benchmark_warmups"]?.takeIfNotBlank()?.toInt() ?: 5
iterations = properties["benchmark_iterations"]?.takeIfNotBlank()?.toInt() ?: 10
iterationTime = properties["benchmark_iteration_time"]?.takeIfNotBlank()?.toLong() ?: 1L
Expand All @@ -59,6 +59,12 @@ benchmark {
param("objectPath", "$projectDir/data/openapi.json", "$projectDir/data/openapi-invalid.json")
param("schemaPath", "$projectDir/data/schemas/openapi_schema.json")
}
getByName("main") {
include(".*Common.*Bench.*")
}
create("comparison") {
include(".*Comparison.*Benchmark.*")
}
}
targets {
register("jvm")
Expand Down
Loading