mirror of
https://github.com/RussellChamp/advent-of-code-2021.git
synced 2026-10-28 06:02:31 +00:00
15 lines
212 B
Go
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)
|
|
}
|