Skip to content

Commit

Permalink
Merge branch 'jvmtests'
Browse files Browse the repository at this point in the history
  • Loading branch information
cpw committed Sep 24, 2023
2 parents 38555d0 + d98ff13 commit ca8cf34
Show file tree
Hide file tree
Showing 3 changed files with 109 additions and 0 deletions.
41 changes: 41 additions & 0 deletions .github/workflows/collect_jmh_results.groovy
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
import groovy.json.JsonSlurper
import net.steppschuh.markdowngenerator.table.Table

import java.nio.file.Files
import java.nio.file.Path

@GrabResolver(name='jitpack.io', root='https://jitpack.io/')
@GrabResolver(name = 'central', root='https://repo1.maven.org/maven2/')
@Grapes([
@Grab('org.apache.groovy:groovy-json:4.0.13'),
@Grab('com.github.Steppschuh:Java-Markdown-Generator:1.3.2')
])

final dummyClassResults = [:]
final noopResults = [:]

final resultsPath = Path.of('jmh_results')
Files.list(resultsPath).map { it.resolve('result.json') }
.map { [new JsonSlurper().parse(it.toFile()), it.parent.fileName.toString().substring('jmh_'.length())] }
.forEach {
dummyClassResults[it[1]] = "${it[0][0].primaryMetric.score.round(2)} ± ${it[0][0].primaryMetric.scoreError.round(2)} ${it[0][0].primaryMetric.scoreUnit}"
noopResults[it[1]] = "${it[0][1].primaryMetric.score.round(2)} ± ${it[0][1].primaryMetric.scoreError.round(2)} ${it[0][1].primaryMetric.scoreUnit}"
}

Table.Builder dummyClassTable = new Table.Builder()
.withAlignments(Table.ALIGN_RIGHT, Table.ALIGN_RIGHT)
.addRow('JDK name & Version', 'Benchmark results')
dummyClassResults.sort { a, b -> a.value <=> b.value }.forEach { type, results -> dummyClassTable.addRow(type, results) }

Table.Builder noopTable = new Table.Builder()
.withAlignments(Table.ALIGN_RIGHT, Table.ALIGN_RIGHT)
.addRow('JDK name & Version', 'Benchmark results')
noopResults.sort { a, b -> a.value <=> b.value }.forEach { type, results -> noopTable.addRow(type, results) }

new File('jmh_results.md').text = """
# `cpw.mods.modlauncher.benchmarks.TransformBenchmark.transformDummyClass` results
${dummyClassTable.build()}
# `cpw.mods.modlauncher.benchmarks.TransformBenchmark.transformNoop` results
${noopTable.build()}
"""
67 changes: 67 additions & 0 deletions .github/workflows/test_jvms.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
name: Test JVMs and publish Jmh results

on:
push:
branches:
- main
workflow_dispatch:
pull_request:
types: [opened, synchronize]

jobs:
testjdks:
name: Test JDK ${{ matrix.jdk }} version ${{ matrix.jvm_version }}
runs-on: ubuntu-latest
strategy:
max-parallel: 10
fail-fast: false
matrix:
jvm_version: [ 17, 18, 19, 20 ]
jdk: [ Graal_VM, Adoptium, Azul, IBM, Oracle, Amazon, BellSoft, SAP ]
exclude:
- jdk: Graal_VM
jvm_version: 18 # Graal doesn't have a dedicated J18 version
include:
- jdk: Microsoft
jvm_version: 17 # MS OpenJDK only has 11 and 177
steps:
- name: Checkout repository
uses: actions/checkout@main
with:
fetch-depth: 0
- name: Setup Gradle
uses: gradle/gradle-build-action@v2
with:
cache-disabled: true
generate-job-summary: false
- name: Make gradlew executable
run: chmod +x ./gradlew
- name: Run Jmh with Gradle Wrapper
run: ./gradlew :jmh -PjmhVendor=${{ matrix.jdk }} -PjmhVersion=${{ matrix.jvm_version }}
- uses: actions/upload-artifact@v3
name: Upload Results
with:
name: jmh_${{ matrix.jdk }}-${{ matrix.jvm_version }}
path: build/reports/jmh/result.json

upload_results:
name: Upload Jmh results
needs: [testjdks]
runs-on: ubuntu-latest
if: ${{ always() }}
steps:
- name: Setup Groovy
uses: wtfjoke/setup-groovy@v1
with:
groovy-version: '4.x'
- name: Checkout repository
uses: actions/checkout@main
- name: Downloads results
uses: actions/download-artifact@v3
id: download
with:
path: jmh_results
- name: Collect results
run: groovy .github/workflows/collect_jmh_results.groovy
- name: Upload Final Results
run: cat jmh_results.md >> $GITHUB_STEP_SUMMARY
1 change: 1 addition & 0 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -111,6 +111,7 @@ task jmh(type: JavaExec) {
final results = file("${project.reportsDir}/jmh/result.json")
doFirst {
results.parentFile.mkdirs()

jvmArgs(
'--module-path', sourceSets.jmh.runtimeClasspath.asPath,
'--add-modules', 'ALL-MODULE-PATH',
Expand Down

0 comments on commit ca8cf34

Please sign in to comment.