add timing tests to day5

This commit is contained in:
RussellChamp committed 2021-12-05 17:47:00 -05:00
1 parent 7f76abf47a
commit 6226b37c5b
4 files changed
+90 -25

No files matched your search

+14
View File
@@ -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)
}