-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add multiplatform targets and benchmarks
- Loading branch information
Showing
15 changed files
with
2,342 additions
and
10 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,6 @@ | ||
# generated by Gradle Wrapper | ||
kt/gradlew linguist-generated | ||
kt/gradlew.bat linguist-generated | ||
|
||
# generated by Kotlin/JS | ||
kt/kotlin-js-store/yarn.lock |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,122 @@ | ||
name: Kotlin benchmarks | ||
|
||
on: | ||
workflow_dispatch: | ||
|
||
permissions: | ||
contents: write | ||
|
||
jobs: | ||
get-inputs: | ||
uses: ephemient/aoc2024/.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@v4 | ||
with: | ||
node-version: 18 | ||
cache: npm | ||
- run: npm install | ||
- run: npm run providedZip | ||
env: | ||
NODE_OPTIONS: --openssl-legacy-provider | ||
- uses: actions/upload-artifact@v4 | ||
with: | ||
name: jmh-visualizer | ||
path: jmh-visualizer.zip | ||
|
||
assemble: | ||
runs-on: ubuntu-latest | ||
|
||
steps: | ||
- uses: actions/checkout@v4 | ||
- uses: actions/setup-java@v4 | ||
with: | ||
distribution: temurin | ||
java-version: 21 | ||
- uses: gradle/actions/setup-gradle@v4 | ||
- run: ./gradlew assembleBenchmarks | ||
working-directory: kt | ||
|
||
build: | ||
needs: [ assemble, get-inputs ] | ||
runs-on: ubuntu-latest | ||
strategy: | ||
matrix: | ||
target: [ jvm, js, linuxX64 ] | ||
|
||
steps: | ||
- uses: actions/checkout@v4 | ||
- uses: actions/download-artifact@v4 | ||
with: | ||
name: inputs | ||
path: inputs | ||
- uses: actions/setup-java@v4 | ||
with: | ||
distribution: temurin | ||
java-version: 21 | ||
- uses: gradle/actions/setup-gradle@v4 | ||
with: | ||
cache-read-only: true | ||
- run: ./gradlew ${{ matrix.target }}Benchmark | ||
working-directory: kt | ||
env: | ||
AOC2024_DATADIR: ${{ github.workspace }}/inputs | ||
- uses: actions/upload-artifact@v4 | ||
with: | ||
name: ${{ matrix.target }}-benchmarks | ||
path: kt/aoc2024-exe/build/reports/benchmarks | ||
|
||
docs: | ||
needs: [ jmh-visualizer, build ] | ||
runs-on: ubuntu-latest | ||
|
||
steps: | ||
- uses: actions/checkout@v4 | ||
with: | ||
ref: gh-docs | ||
- uses: actions/download-artifact@v4 | ||
with: | ||
name: jmh-visualizer | ||
- uses: actions/download-artifact@v4 | ||
with: | ||
name: jvm-benchmarks | ||
path: benchmarks | ||
- uses: actions/download-artifact@v4 | ||
with: | ||
name: js-benchmarks | ||
path: benchmarks | ||
- uses: actions/download-artifact@v4 | ||
with: | ||
name: linuxX64-benchmarks | ||
path: benchmarks | ||
- run: rm -rf jmh-visualizer | ||
- run: unzip -d jmh-visualizer jmh-visualizer.zip | ||
- name: Create provided.js | ||
run: | | ||
shopt -s failglob | ||
names=() jsonargs=() | ||
for file in benchmarks/main/*/*.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]|sort_by(.benchmark|[split("[.]|(?<!\\d)(?!\\D)|(?<!\\D)(?!\\d)")|map(try tonumber catch .),.]))' "${jsonargs[@]}"); | ||
EOF | ||
- uses: EndBug/add-and-commit@v9 | ||
with: | ||
add: jmh-visualizer | ||
message: 'kotlinx.benchmark ${{ github.sha }}' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
23 changes: 23 additions & 0 deletions
23
kt/aoc2024-exe/src/commonBench/kotlin/com/github/ephemient/aoc2024/exe/Day1Bench.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
package com.github.ephemient.aoc2024.exe | ||
|
||
import com.github.ephemient.aoc2024.Day1 | ||
import kotlinx.benchmark.Benchmark | ||
import kotlinx.benchmark.Scope | ||
import kotlinx.benchmark.Setup | ||
import kotlinx.benchmark.State | ||
|
||
@State(Scope.Benchmark) | ||
class Day1Bench { | ||
private lateinit var input: String | ||
|
||
@Setup | ||
fun setup() { | ||
input = getDayInput(1) | ||
} | ||
|
||
@Benchmark | ||
fun part1() = Day1(input).part1() | ||
|
||
@Benchmark | ||
fun part2() = Day1(input).part2() | ||
} |
Oops, something went wrong.