]> Cypherpunks.ru repositories - gostls13.git/commitdiff
testing: use time.Since instead of time.Now().Sub
authorDaniel Martí <mvdan@mvdan.cc>
Wed, 6 Sep 2017 19:13:06 +0000 (21:13 +0200)
committerDaniel Martí <mvdan@mvdan.cc>
Wed, 6 Sep 2017 19:47:37 +0000 (19:47 +0000)
Change-Id: Ia0479f65a6ef033a65acf9ac8692777839a53b8c
Reviewed-on: https://go-review.googlesource.com/61990
Run-TryBot: Daniel Martí <mvdan@mvdan.cc>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>

src/testing/benchmark.go
src/testing/example.go
src/testing/testing.go

index d592afbf87da3253fd3789900791a6d625cc7360..2d0de180d71863f9b30a72cee389221091c0d555 100644 (file)
@@ -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
index e5bce7af4e7a3e6a691e6f42e097e51d69e2fd9c..b9955500e66d9242188f854d90aa2d3af23b376a 100644 (file)
@@ -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()
index 8b4bfc31a82e51c15a02fc111e92770422f01843..a170cd0fd9a46e222f6288ca80e6eb8ae9120640 100644 (file)
@@ -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 {