Add functionality to run and time all days

This commit is contained in:
bdnugget committed 2024-12-16 14:45:48 +01:00
1 parent 38b842213c
commit 842dd4ec8a
6 files changed
+23

No files matched your search

View File
File renamed without changes.
File renamed without changes.
View File
File renamed without changes.
View File
File renamed without changes.
+3
View File
@@ -0,0 +1,3 @@
module github.com/bdnugget/AoC_2024
go 1.23.4
+20
View File
@@ -0,0 +1,20 @@
package main
import (
"fmt"
"time"
"github.com/bdnugget/AoC_2024/day01"
)
func measureAndPrint[T any](label string, fn func() T) {
startTime := time.Now()
res := fn()
endTime := time.Now()
elapsed := endTime.Sub(startTime)
fmt.Printf("%s: %-15v\t(%v)\n", label, res, elapsed)
}
func main() {
measureAndPrint("Day 01 part 01", day01.Part01)
}