mirror of
https://github.com/RussellChamp/advent-of-code-2021.git
synced 2026-10-27 21:52:32 +00:00
add timing tests to day5
This commit is contained in:
1 parent
7f76abf47a
commit
6226b37c5b
4 files changed
+90
-25
No files matched your search
@@ -0,0 +1,14 @@
|
||||
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)
|
||||
}
|
||||
Reference in new issue
Block a user