From: Daniel Martí Date: Wed, 6 Sep 2017 19:13:06 +0000 (+0200) Subject: testing: use time.Since instead of time.Now().Sub X-Git-Tag: go1.10beta1~1206 X-Git-Url: http://www.git.cypherpunks.su/?a=commitdiff_plain;h=261a8d9abdc569a864a2cde37f9b5697501a212d;p=gostls13.git testing: use time.Since instead of time.Now().Sub Change-Id: Ia0479f65a6ef033a65acf9ac8692777839a53b8c Reviewed-on: https://go-review.googlesource.com/61990 Run-TryBot: Daniel Martí Reviewed-by: Ian Lance Taylor TryBot-Result: Gobot Gobot --- diff --git a/src/testing/benchmark.go b/src/testing/benchmark.go index d592afbf87..2d0de180d7 100644 --- a/src/testing/benchmark.go +++ b/src/testing/benchmark.go @@ -86,7 +86,7 @@ func (b *B) StartTimer() { // want to measure. func (b *B) StopTimer() { if b.timerOn { - b.duration += time.Now().Sub(b.start) + b.duration += time.Since(b.start) runtime.ReadMemStats(&memStats) b.netAllocs += memStats.Mallocs - b.startAllocs b.netBytes += memStats.TotalAlloc - b.startBytes diff --git a/src/testing/example.go b/src/testing/example.go index e5bce7af4e..b9955500e6 100644 --- a/src/testing/example.go +++ b/src/testing/example.go @@ -87,7 +87,7 @@ func runExample(eg InternalExample) (ok bool) { // Clean up in a deferred call so we can recover if the example panics. defer func() { - dstr := fmtDuration(time.Now().Sub(start)) + dstr := fmtDuration(time.Since(start)) // Close pipe, restore stdout, get output. w.Close() diff --git a/src/testing/testing.go b/src/testing/testing.go index 8b4bfc31a8..a170cd0fd9 100644 --- a/src/testing/testing.go +++ b/src/testing/testing.go @@ -701,7 +701,7 @@ func tRunner(t *T, fn func(t *T)) { t.Errorf("race detected during execution of test") } - t.duration += time.Now().Sub(t.start) + t.duration += time.Since(t.start) // If the test panicked, print any test output before dying. err := recover() if !t.finished && err == nil {