Add JMH benchmarks to CI with performance regression detection#26
Add JMH benchmarks to CI with performance regression detection#26
Conversation
Co-authored-by: thebeanogamer <3729048+thebeanogamer@users.noreply.github.com>
Co-authored-by: thebeanogamer <3729048+thebeanogamer@users.noreply.github.com>
Co-authored-by: thebeanogamer <3729048+thebeanogamer@users.noreply.github.com>
thebeanogamer
left a comment
There was a problem hiding this comment.
Automatically fail the CI check if performance has meaningfully regressed since the previous commit on the default branch
There was a problem hiding this comment.
Pull Request Overview
This PR integrates JMH benchmarks into the CI pipeline to automatically run performance benchmarks and publish results as artifacts. The implementation addresses the requirement to run existing Base58 encoding and crypto operation benchmarks as part of CI.
- Added three new Gradle tasks for building, running, and reporting JMH benchmarks with configurable parameters
- Integrated a new GitHub Actions job that runs benchmarks on every push/PR and uploads results as artifacts
- Updated documentation with comprehensive instructions for running benchmarks locally and accessing CI results
Reviewed Changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated 6 comments.
| File | Description |
|---|---|
| message-encoding/build.gradle | Added three Gradle tasks (jmhJar, jmh, jmhReport) for benchmark execution with configurable parameters |
| .github/workflows/gradle.yml | Added jmh-benchmarks job to run benchmarks in CI and upload results as artifacts |
| message-encoding/src/jmh-test/README.md | Enhanced documentation with detailed instructions for running benchmarks and accessing CI results |
Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.
| // JMH command line options | ||
| args = [ | ||
| '-rf', 'json', // Result format: JSON | ||
| '-rff', "${project.buildDir}/reports/jmh/results.json", // Result file |
There was a problem hiding this comment.
Use layout.buildDirectory instead of the deprecated project.buildDir property. This should be layout.buildDirectory.dir('reports/jmh/results.json').get().asFile.absolutePath.
|
|
||
| // Create reports directory | ||
| doFirst { | ||
| file("${project.buildDir}/reports/jmh").mkdirs() |
There was a problem hiding this comment.
Use layout.buildDirectory instead of the deprecated project.buildDir property. This should be layout.buildDirectory.dir('reports/jmh').get().asFile.mkdirs().
|
|
||
| // Print results location after execution | ||
| doLast { | ||
| println "JMH benchmark results written to: ${project.buildDir}/reports/jmh/results.json" |
There was a problem hiding this comment.
Use layout.buildDirectory instead of the deprecated project.buildDir property. This should reference layout.buildDirectory.dir('reports/jmh/results.json').get().asFile.absolutePath.
| // JMH command line options | ||
| args = [ | ||
| '-rf', 'text', // Result format: text | ||
| '-rff', "${project.buildDir}/reports/jmh/results.txt", // Result file |
There was a problem hiding this comment.
Use layout.buildDirectory instead of the deprecated project.buildDir property. This should be layout.buildDirectory.dir('reports/jmh/results.txt').get().asFile.absolutePath.
| ] | ||
|
|
||
| doFirst { | ||
| file("${project.buildDir}/reports/jmh").mkdirs() |
There was a problem hiding this comment.
Use layout.buildDirectory instead of the deprecated project.buildDir property. This should be layout.buildDirectory.dir('reports/jmh').get().asFile.mkdirs().
| } | ||
|
|
||
| doLast { | ||
| println "JMH benchmark results written to: ${project.buildDir}/reports/jmh/results.txt" |
There was a problem hiding this comment.
Use layout.buildDirectory instead of the deprecated project.buildDir property. This should reference layout.buildDirectory.dir('reports/jmh/results.txt').get().asFile.absolutePath.
| println "JMH benchmark results written to: ${project.buildDir}/reports/jmh/results.txt" | |
| println "JMH benchmark results written to: ${layout.buildDirectory.dir('reports/jmh/results.txt').get().asFile.absolutePath}" |
|
@copilot please action all the reviews |
Co-authored-by: thebeanogamer <3729048+thebeanogamer@users.noreply.github.com>
Added performance regression detection in commit |
|
CI is failing, can you tell me why? If an issue already exists, just update it rather than raising a new one. Put the Python scripts in the repo rather than inlining them in the YAML |
- Use FETCH_HEAD instead of origin/master for checkout - Check if JMH tasks exist on master before attempting baseline build - Handle first-time setup gracefully when master doesn't have JMH tasks - Save baseline results outside build directory to avoid conflicts - Add clearer status messages with emoji indicators Co-authored-by: thebeanogamer <3729048+thebeanogamer@users.noreply.github.com>
Fixed the CI workflow issues in commit Issues identified and resolved:
The workflow will now gracefully handle first-time setup and only run comparisons when master has the JMH infrastructure. |
Co-authored-by: thebeanogamer <3729048+thebeanogamer@users.noreply.github.com>
Summary
Successfully integrated JMH benchmarks into CI pipeline with regression detection:
jmh(JSON output),jmhReport(text output),jmhJar(build executable JAR)message-encoding/build/reports/jmh/directoryOriginal prompt
💡 You can make Copilot smarter by setting up custom instructions, customizing its development environment and configuring Model Context Protocol (MCP) servers. Learn more Copilot coding agent tips in the docs.