Skip to content

Commit

Permalink
Merge pull request #171 from ephemient/kt/day17jvm
Browse files Browse the repository at this point in the history
Better sort day 17 benchmarks
  • Loading branch information
ephemient authored Dec 26, 2024
2 parents 69d702d + b083aab commit bd4c7a8
Show file tree
Hide file tree
Showing 5 changed files with 89 additions and 49 deletions.
6 changes: 6 additions & 0 deletions kt/aoc2024-exe/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,12 @@ kotlin {
group("nonblocking") {
withWasmJs()
}
group("nonJvm") {
group("native") {
withNative()
}
withWasmJs()
}
}
}

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,77 @@
package com.github.ephemient.aoc2024.exe

import com.github.ephemient.aoc2024.Day17
import com.github.ephemient.aoc2024.Day17Jvm
import kotlinx.benchmark.Benchmark
import kotlinx.benchmark.Blackhole
import kotlinx.benchmark.Scope
import kotlinx.benchmark.Setup
import kotlinx.benchmark.State

@State(Scope.Benchmark)
class Day17Bench {
private lateinit var input: String
private lateinit var day17: Day17
private var day17Jvm: Day17Jvm? = null

@Setup
fun setup() {
input = getDayInput(17)
day17 = Day17(input)
day17Jvm = try {
Day17Jvm(input)
} catch (_: AssertionError) {
null
}
}

@Benchmark
fun part1() = Day17(input).part1()

@Benchmark
fun part1_cached() = day17.part1()

@Benchmark
fun part1_jvm() = Day17Jvm(input).part1()

@Benchmark
fun part1_jvm_cached() = day17Jvm!!.part1()

@Benchmark
fun part2() = Day17(input).part2()

@Benchmark
fun part2_cached() = day17.part2()

@Benchmark
fun part2_jvm() = Day17Jvm(input).part2()

@Benchmark
fun part2_jvm_cached() = day17Jvm!!.part2()

@Benchmark
fun solve(bh: Blackhole) {
val day17 = Day17(input)
bh.consume(day17.part1())
bh.consume(day17.part2())
}

@Benchmark
fun solve_cached(bh: Blackhole) {
bh.consume(day17.part1())
bh.consume(day17.part2())
}

@Benchmark
fun solve_jvm(bh: Blackhole) {
val day17Jvm = Day17Jvm(input)
bh.consume(day17Jvm.part1())
bh.consume(day17Jvm.part2())
}

@Benchmark
fun solve_jvm_cached(bh: Blackhole) {
bh.consume(day17Jvm!!.part1())
bh.consume(day17Jvm!!.part2())
}
}

This file was deleted.

10 changes: 6 additions & 4 deletions kt/graalvm/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,9 @@ val benchmarkRun by tasks.registering(JavaExec::class) {
mainClass = "org.openjdk.jmh.Main"
classpath(benchmark.output, benchmark.runtimeClasspath)
args("-f", 0, "-wi", 1, "-w", "0s", "-r", "0s", "-bm", "avgt", "-tu", "us", "-i", 1)
args("-rf", "json", "-rff", "/dev/null")
args("-rf", "json", "-rff", "/dev/null", "-e", "jvm")
project.findProperty("benchmarkExclude")?.let { args("-e", it) }
project.findProperty("benchmarkInclude")?.let { args(it) }
outputs.dir(AgentConfigurationFactory.getAgentOutputDirectoryForTask(layout, name))
}
val syncBenchmarkRunMetadata by tasks.registering(Sync::class) {
Expand All @@ -43,9 +45,9 @@ graalvmNative {
classpath(syncBenchmarkRunMetadata, benchmark.output, benchmark.runtimeClasspath)
runtimeArgs("-f", 0, "-wi", 1, "-w", "1s", "-r", "1s", "-bm", "avgt", "-tu", "us")
val benchmarkFile = benchmarkDir.get().file("graalvmBench.json")
runtimeArgs("-rf", "json", "-rff", benchmarkFile.asFile)
findProperty("benchmarkExclude")?.let { runtimeArgs("-e", it) }
findProperty("benchmarkInclude")?.let { runtimeArgs(it) }
runtimeArgs("-rf", "json", "-rff", benchmarkFile.asFile, "-e", "jvm")
project.findProperty("benchmarkExclude")?.let { runtimeArgs("-e", it) }
project.findProperty("benchmarkInclude")?.let { runtimeArgs(it) }
}
}
agent {
Expand Down

0 comments on commit bd4c7a8

Please sign in to comment.