This program
package main
import (
"fmt"
"time"
)
func main() {
timer := time.NewTicker(time.Nanosecond).C
start := time.Now()
for i := 0; i < 100; i++ {
<-timer
}
fmt.Printf("%v\n", time.Now().Sub(start))
}
prints
- "1.56252s" on my Windows XP;
- "196.2966ms" on my Windows 7;
- "10.114019ms" on my Linux;
Which one is correct?
I would expect it to print something like "100ns". Perhaps I am wrong.
Alex