std :: chrono time_since_epoch的默认持续时间 [英] std::chrono default duration for time_since_epoch

查看:2890
本文介绍了std :: chrono 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屋!

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