2024-02-25 00:55:09 +00:00
|
|
|
package main
|
|
|
|
|
2024-02-25 02:17:52 +00:00
|
|
|
import (
|
|
|
|
"advent-20/solutions"
|
|
|
|
"fmt"
|
2024-02-25 20:59:49 +00:00
|
|
|
"time"
|
2024-02-25 02:17:52 +00:00
|
|
|
)
|
2024-02-25 00:55:09 +00:00
|
|
|
|
|
|
|
func main() {
|
2024-02-25 20:59:49 +00:00
|
|
|
runAndBenchmark("01", "1", false, solutions.Day01Part01)
|
|
|
|
runAndBenchmark("01", "2", false, solutions.Day01Part02)
|
2024-02-25 20:40:20 +00:00
|
|
|
|
2024-02-25 21:37:21 +00:00
|
|
|
runAndBenchmark("02", "1", false, solutions.Day02Part01)
|
|
|
|
runAndBenchmark("02", "2", false, solutions.Day02Part02)
|
|
|
|
|
|
|
|
runAndBenchmark("03", "1", false, solutions.Day03Part01)
|
2024-02-25 21:43:55 +00:00
|
|
|
runAndBenchmark("03", "2", false, solutions.Day03Part02)
|
2024-02-27 14:06:01 +00:00
|
|
|
|
|
|
|
runAndBenchmark("04", "1", false, solutions.Day04Part01)
|
|
|
|
runAndBenchmark("04", "2", false, solutions.Day04Part02)
|
2024-03-01 14:05:46 +00:00
|
|
|
|
|
|
|
runAndBenchmark("05", "1", false, solutions.Day05Part01)
|
2024-03-01 14:24:23 +00:00
|
|
|
runAndBenchmark("05", "2", false, solutions.Day05Part02)
|
2024-02-25 20:59:49 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
type execute func(bool) int
|
|
|
|
|
|
|
|
func runAndBenchmark(day, part string, isTest bool, fn execute) {
|
|
|
|
startMs := time.Now().UnixMicro()
|
|
|
|
computation := fn(isTest)
|
|
|
|
endMs := time.Now().UnixMicro()
|
|
|
|
duration := endMs - startMs
|
2024-02-25 21:43:55 +00:00
|
|
|
fmt.Printf("Day %s part %s:\t%12d\t%5d micros.\n", day, part, computation, duration)
|
2024-02-25 00:55:09 +00:00
|
|
|
}
|