如何使我的系统支持纳秒精度 [英] How to make my system support nano seconds precision

查看:349
本文介绍了如何使我的系统支持纳秒精度的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

当我从此页面 high_precision_timer 运行代码时,我得知我的系统只支持微秒精度。

When I run the code from this page high_precision_timer, I got to know my system only support microsecond precision.

根据文档


cout< chrono :: high_resolution_clock :: period :: den< endl;

cout << chrono::high_resolution_clock::period::den << endl;

请注意,并不保证
每秒钟有多少刻度,只是它是最高的。因此,我们
做的第一件事是获得精度,通过打印多少次第二
时钟滴答。我的系统每秒提供1000000个tick,这是
a microsecond的精度。

Note, that there isn’t a guarantee how many the ticks per seconds it has, only that it’s the highest available. Hence, the first thing we do is to get the precision, by printing how many many times a second the clock ticks. My system provides 1000000 ticks per second, which is a microsecond precision.

我也得到完全相同的值1000000 tick每秒 。这意味着我的系统也支持微秒精度。

I am also getting exactly the same value 1000000 ticks per second . That means my system is also support microseconds precision.

每次运行任何程序时,我总是得到xyz microsecar和xyz000 nanosec的值。我认为上面的不支持我的系统到nanosec可能是原因。

Everytime I run any program , I always get value xyz microsecond and xyz000 nanosec . I think the above non-support of my system to nanosec may be the reason.

有什么办法让我的系统nanosec支持吗?

Is there any way to make my system nanosec supportive ?

推荐答案

考虑这个,
现在大多数处理器以约1到3GHz的频率操作,即说2 * 10 ^ 9Hz。
,这意味着在处理器级别每隔0.5纳秒1个刻度。所以我想你的机会非常非常苗条。

Consider this, Most processors today operate at a frequency of about 1 to 3 GHz i.e. say 2 * 10^9 Hz. which means 1 tick every 0.5 nano seconds at the processor level. so i would guess your chances are very very slim.

编辑:
尽管文档仍然稀疏为此我记得读,它访问RTC的CPU(不确定),其频率是固定的。
作为一个建议,我认为以毫秒为单位的测量性能与以微秒为单位的测量相比没有什么优势(除非它用于医疗用途)。

though the documentation is still sparse for this I remember reading that it accesses the RTC of the CPU(not sure), whose frequency is fixed. Also as an advice i think measuring performance in nano second has little advantage compared to measuring in micro sec ( unless its for medical use ;) ).

看看这个问题及其答案。我认为它可以更有意义
HPET的频率与CPU频率的测量时间

and take a look at this question and its answer. I think it can make more sense HPET's frequency vs CPU frequency for measuring time

这篇关于如何使我的系统支持纳秒精度的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆