Go – 系统时间以皮秒为单位

huangapple go评论83阅读模式
英文:

Go - System Time in pico-second

问题

在Go语言中,能否以比纳秒更小的单位(如皮秒)获取系统时间?实际上,我想要测量两个连续事件之间的时间间隔,但在我们的快速系统中无法以纳秒的精度捕捉到。

英文:

Is it possible in go to get system time in less than nano second means in pico-second or like that? Actually, I want to measure two consecutive events time gap which I can't catch in nano-second in our fast system.

答案1

得分: 4

在现代硬件上调用性能分析函数/指令的成本比你要测量的时间间隔更大(并且更容易受到扩散和偏差的影响)。所以即使你尝试,你也会得到错误的结果。

如果可能的话,考虑跟踪100个事件的时间间隔。

英文:

The cost of calling profiling functions/instructions on modern hardware is larger (and mor espread and prone to deviance) than the interval you're going to measure. So even if you try, you'll get erroneous results.

Consider tracking time lapse for 100 events, if that's at all possible.

答案2

得分: 3

时间分辨率取决于硬件和操作系统。Go的time.Nanoseconds函数提供了纳秒级的时间分辨率。在PC上,通常为1000纳秒(1微秒),或者最好的情况下为100纳秒。

英文:

The time resolution is hardware and operating system dependent. The Go time.Nanoseconds function provides up to nanosecond time resolution. On a PC, it's usually 1000 nanoseconds (1 microsecond) or 100 nanoseconds at best.

huangapple
  • 本文由 发表于 2011年12月6日 14:17:49
  • 转载请务必保留本文链接:https://go.coder-hub.com/8396082.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定