-
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.
Merge pull request #171 from ephemient/kt/day17jvm
Better sort day 17 benchmarks
- Loading branch information
Showing
5 changed files
with
89 additions
and
49 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
77 changes: 77 additions & 0 deletions
77
kt/aoc2024-exe/src/jvmBench/kotlin/com/github/ephemient/aoc2024/exe/Day17Bench.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,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()) | ||
} | ||
} |
45 changes: 0 additions & 45 deletions
45
kt/aoc2024-exe/src/jvmBench/kotlin/com/github/ephemient/aoc2024/exe/Day17JvmBench.kt
This file was deleted.
Oops, something went wrong.
File renamed without changes.
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