Join us for Day 3 of Advent of Code 2022! :dizzy: ...
# advent-of-code
k
Join us for Day 3 of Advent of Code 2022! 💫 It’s starting today at 5:00 PM UTC. There will be opportunities for you to ask questions. See you there!

https://www.youtube.com/watch?v=IPLfo4zXNjkâ–ľ

k
I can't make it to the stream today, but if someone is in the mood of relaying a question, could you ask what their opinion is of using ai to solve the aoc challenges?
x
Was looking into setting up
kotlinx.benchmark
on my aoc project as they did on this stream. Do i need to wrap all my functions in a class just for it to be benchmarked? Can I not benchmark top-level functions?
m
my benchmark class ended up like this after I re-organised my templates today, I think you could call a top level function in there. You don’t need to call the benchmark class anywhere, the gradle task will find it by reflection.
Copy code
@State(Scope.Benchmark)
@Fork(1)
@Warmup(iterations = 0)
@Measurement(iterations = 3, time = 1, timeUnit = TimeUnit.SECONDS)
open class DayBenchmark{

    private var input: List<String> = emptyList()
    private val day = Day04
    @Setup
    fun setUp() {
        input = readInput(day.number, "Day")
    }

    @Benchmark
    fun part1(): Long = day.part1(input) // I think you could call any function here, even a top level one

    @Benchmark
    fun part2(): Long = day.part2(input)

    @Benchmark
    fun part1Alternative(): Long = day.part1Set(input)

    @Benchmark
    fun part2Alternative(): Long = day.part2Set(input)

}