mirror of
https://github.com/golang/go
synced 2024-11-20 04:44:40 -07:00
testing: use time.Since instead of time.Now().Sub
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>
This commit is contained in:
parent
6367c19f26
commit
261a8d9abd
@ -86,7 +86,7 @@ func (b *B) StartTimer() {
|
|||||||
// want to measure.
|
// want to measure.
|
||||||
func (b *B) StopTimer() {
|
func (b *B) StopTimer() {
|
||||||
if b.timerOn {
|
if b.timerOn {
|
||||||
b.duration += time.Now().Sub(b.start)
|
b.duration += time.Since(b.start)
|
||||||
runtime.ReadMemStats(&memStats)
|
runtime.ReadMemStats(&memStats)
|
||||||
b.netAllocs += memStats.Mallocs - b.startAllocs
|
b.netAllocs += memStats.Mallocs - b.startAllocs
|
||||||
b.netBytes += memStats.TotalAlloc - b.startBytes
|
b.netBytes += memStats.TotalAlloc - b.startBytes
|
||||||
|
@ -87,7 +87,7 @@ func runExample(eg InternalExample) (ok bool) {
|
|||||||
|
|
||||||
// Clean up in a deferred call so we can recover if the example panics.
|
// Clean up in a deferred call so we can recover if the example panics.
|
||||||
defer func() {
|
defer func() {
|
||||||
dstr := fmtDuration(time.Now().Sub(start))
|
dstr := fmtDuration(time.Since(start))
|
||||||
|
|
||||||
// Close pipe, restore stdout, get output.
|
// Close pipe, restore stdout, get output.
|
||||||
w.Close()
|
w.Close()
|
||||||
|
@ -701,7 +701,7 @@ func tRunner(t *T, fn func(t *T)) {
|
|||||||
t.Errorf("race detected during execution of test")
|
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.
|
// If the test panicked, print any test output before dying.
|
||||||
err := recover()
|
err := recover()
|
||||||
if !t.finished && err == nil {
|
if !t.finished && err == nil {
|
||||||
|
Loading…
Reference in New Issue
Block a user