Commit 5e585830 authored by Russ Cox's avatar Russ Cox Committed by Brad Fitzpatrick

time: fix example in monotonic time comment

t.Sub(u) would be -20 milliseconds.
The right computation is u.Sub(t), but rewrite to be even clearer.

Thanks to Karsten Weiss for catching this.

Change-Id: I6e274d69b0301840d57c5c65bf4114da0d33bf10
Reviewed-on: https://go-review.googlesource.com/46971
Run-TryBot: Russ Cox <rsc@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: default avatarBrad Fitzpatrick <bradfitz@golang.org>
parent 1a56a27c
...@@ -23,10 +23,10 @@ ...@@ -23,10 +23,10 @@
// approximately 20 milliseconds, even if the wall clock is changed during // approximately 20 milliseconds, even if the wall clock is changed during
// the operation being timed: // the operation being timed:
// //
// t := time.Now() // start := time.Now()
// ... operation that takes 20 milliseconds ... // ... operation that takes 20 milliseconds ...
// u := time.Now() // t := time.Now()
// elapsed := t.Sub(u) // elapsed := t.Sub(start)
// //
// Other idioms, such as time.Since(start), time.Until(deadline), and // Other idioms, such as time.Since(start), time.Until(deadline), and
// time.Now().Before(deadline), are similarly robust against wall clock // time.Now().Before(deadline), are similarly robust against wall clock
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment