Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add both() to all benchmarks #49

Merged
merged 1 commit into from
Dec 6, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package com.github.ephemient.aoc2024.exe

import com.github.ephemient.aoc2024.Day1
import kotlinx.benchmark.Benchmark
import kotlinx.benchmark.Blackhole
import kotlinx.benchmark.Scope
import kotlinx.benchmark.Setup
import kotlinx.benchmark.State
Expand All @@ -20,4 +21,11 @@ class Day1Bench {

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

@Benchmark
fun both(bh: Blackhole) {
val day1 = Day1(input)
bh.consume(day1.part1())
bh.consume(day1.part2())
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package com.github.ephemient.aoc2024.exe

import com.github.ephemient.aoc2024.Day2
import kotlinx.benchmark.Benchmark
import kotlinx.benchmark.Blackhole
import kotlinx.benchmark.Scope
import kotlinx.benchmark.Setup
import kotlinx.benchmark.State
Expand All @@ -20,4 +21,11 @@ class Day2Bench {

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

@Benchmark
fun both(bh: Blackhole) {
val day2 = Day2(input)
bh.consume(day2.part1())
bh.consume(day2.part2())
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package com.github.ephemient.aoc2024.exe

import com.github.ephemient.aoc2024.Day3
import kotlinx.benchmark.Benchmark
import kotlinx.benchmark.Blackhole
import kotlinx.benchmark.Scope
import kotlinx.benchmark.Setup
import kotlinx.benchmark.State
Expand All @@ -20,4 +21,11 @@ class Day3Bench {

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

@Benchmark
fun both(bh: Blackhole) {
val day3 = Day3(input)
bh.consume(day3.part1())
bh.consume(day3.part2())
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package com.github.ephemient.aoc2024.exe

import com.github.ephemient.aoc2024.Day4
import kotlinx.benchmark.Benchmark
import kotlinx.benchmark.Blackhole
import kotlinx.benchmark.Scope
import kotlinx.benchmark.Setup
import kotlinx.benchmark.State
Expand All @@ -20,4 +21,11 @@ class Day4Bench {

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

@Benchmark
fun both(bh: Blackhole) {
val day4 = Day4(input)
bh.consume(day4.part1())
bh.consume(day4.part2())
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ class Day5(input: String) {

fun part1() = correct.sumOf { it[it.size / 2] }

fun part2(): Int = incorrect.sumOf {
fun part2() = incorrect.sumOf {
val pages = it.toMutableList()
for (i in pages.indices) {
while (true) {
Expand Down
Loading