-
Notifications
You must be signed in to change notification settings - Fork 18.8k
Closed
Labels
Description
- What version of Go are you using (go version)?
go version go1.6 linux/arm64 - What operating system and processor architecture are you using?
ubuntu 14.04 kernel 4.2 aarch64 - What did you do?
run "timer_testing.go" - What did you expect to see?
print "10ms" 10 times - What did you see instead?
some inaccurate duration
Test code "timer_testing.go"
package main
import (
"fmt"
"time"
)
func main() {
tm := time.NewTicker(10e6) // 10ms
t := time.Now()
for i := 0; i < 10; i++ {
<-tm.C
now := time.Now()
fmt.Println(now.Sub(t))
t = now
}
}Run many times, I got some errors like this:
# ./timer_testing
10.156ms
10.023ms
404.745ms # error
13.478ms # error
1.84ms # error
9.934ms
10.006ms
9.998ms
10.001ms
9.998ms
I have some programs that depend on accurate timing, those time error will result of some serious logic errors.