std :: chrono time_since_epoch的默认持续时间 [英] std::chrono default duration for time_since_epoch
问题描述
如果我有以下时钟,并使用它来获取从时钟的时代起的计数,这个计数实际上代表什么。
If I have the following clock and use it to get a count of ticks since the clock's epoch, what does this count actually represent.
std::chrono::high_resolution_clock::now().time_since_epoch().count();
例如我刚刚运行这个,并得到 1389375799048790227
。这个数字是什么意思?
For instance I just ran this and got 1389375799048790227
. What does this number mean? Is it nanoseconds, microseconds, etc?
推荐答案
持续时间的类型是 std :: chrono: :high_resolution_clock :: duration
。您可以通过以下方法检查持续时间的滴答期: std :: chrono :: high_resolution_clock :: duration :: period :: num
和 std :: chrono: :high_resolution_clock :: duration :: period :: den
。这是表示每分钟秒数的分数的分子和分母(例如,对于纳秒为1/1000000000)。
The type of the duration is std::chrono::high_resolution_clock::duration
. You can inspect a duration's tick period with: std::chrono::high_resolution_clock::duration::period::num
and std::chrono::high_resolution_clock::duration::period::den
. This is the numerator and denominator of a fraction representing the amount of seconds per tick (e.g. 1/1000000000 for nanoseconds).
这个纪元是未指定的,但是你是1389375799048790227从您获得结果时的时间间隔。
The epoch is unspecified, but for you is 1389375799048790227 ticks from when you got that result.
这篇关于std :: chrono time_since_epoch的默认持续时间的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!