Files
advent-of-code-2021/utils/timing/timing.go
T
2021-12-05 17:47:00 -05:00

15 lines
212 B
Go

package timing
import "time"
func TimeFunction(fn func(), trials int) time.Duration {
startTime := time.Now()
for i := 0; i < trials; i++ {
fn()
}
endTime := time.Now()
return endTime.Sub(startTime)
}