Skip to content

Commit

Permalink
Add benchmarks
Browse files Browse the repository at this point in the history
  • Loading branch information
ephemient committed Dec 1, 2023
1 parent 7066ec5 commit f01b0dd
Show file tree
Hide file tree
Showing 2 changed files with 117 additions and 0 deletions.
110 changes: 110 additions & 0 deletions .github/workflows/kt-bench.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,110 @@
name: Kotlin benchmarks

on:
workflow_dispatch:

permissions:
contents: write

jobs:
get-inputs:
uses: ephemient/aoc2023/.github/workflows/get-inputs.yml@main
secrets:
SESSION: ${{ secrets.SESSION }}

jmh-visualizer:
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v4
with:
repository: jzillmann/jmh-visualizer
- uses: actions/setup-node@v3
with:
node-version: 18
cache: npm
- run: npm install
- run: npm run providedZip
env:
NODE_OPTIONS: --openssl-legacy-provider
- uses: actions/upload-artifact@v3
with:
name: jmh-visualizer
path: jmh-visualizer.zip

build:
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v4
- uses: actions/setup-java@v4
with:
distribution: temurin
java-version: 17
- uses: gradle/gradle-build-action@v2
with:
arguments: assembleBenchmarks
build-root-directory: kt
- uses: actions/upload-artifact@v3
with:
name: jvmBench
path: kt/aoc2023-exe/build/benchmarks/*/jars/*.jar

run:
needs: [ get-inputs, jmh-visualizer, build ]
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v4
with:
ref: gh-docs
- uses: actions/download-artifact@v3
with:
name: inputs
path: inputs
- uses: actions/download-artifact@v3
with:
name: jmh-visualizer
- uses: actions/download-artifact@v3
with:
name: jvmBench
- run: rm -rf jmh-visualizer
- run: unzip -d jmh-visualizer jmh-visualizer.zip
- uses: actions/setup-java@v4
with:
distribution: temurin
java-version: 17
- name: Run JVM benchmarks
run: |
cat >config <<EOF
name:jvmBench
reportFile:jvmBench.json
traceFormat:text
warmups:1
iterationTime:1
outputTimeUnit:SECONDS
EOF
java -cp jvmBench/jars/*.jar kotlinx.benchmark.jvm.JvmBenchmarkRunnerKt config
env:
AOC2023_DATADIR: inputs
- name: Create provided.js
run: |
shopt -s failglob
names=() jsonargs=()
for file in *.json; do
name=${file##*/}
name=${name%.*}
names+=("$name")
jsonargs+=(--slurpfile "$name" "$file")
done
cat >jmh-visualizer/provided.js <<EOF
// provided.js - generated by ${{ github.repository }}/${{ github.workflow }}, $(date +'%Y-%m-%d %H:%M:%S.%N')
var providedBenchmarks = $(jq --null-input --compact-output '$ARGS.positional|unique' --args "${names[@]}");
var providedBenchmarkStore = $(jq --null-input '$ARGS.named|map_values(.[0])' "${jsonargs[@]}");
EOF
- uses: EndBug/add-and-commit@v9
with:
add: jmh-visualizer
message: 'kotlinx.benchmark ${{ github.sha }}'
7 changes: 7 additions & 0 deletions kt/aoc2023-exe/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -62,4 +62,11 @@ benchmark {
targets {
register("jvmTest")
}
configurations {
getByName("main") {
warmups = 1
iterationTime = 1
outputTimeUnit = "SECONDS"
}
}
}

0 comments on commit f01b0dd

Please sign in to comment.