advent-20/main.go

26 lines
621 B
Go
Raw Normal View History

2024-02-25 00:55:09 +00:00
package main
import (
"advent-20/solutions"
"fmt"
2024-02-25 20:59:49 +00:00
"time"
)
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 20:59:49 +00:00
runAndBenchmark("02", "1", false, solutions.Day01Part01)
runAndBenchmark("02", "2", false, solutions.Day01Part02)
}
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
fmt.Printf("Day %s part %s:\t%10d\t%5d micros.\n", day, part, computation, duration)
2024-02-25 00:55:09 +00:00
}