英文:
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.
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论