Android NDK计时时代不正确(std :: chrono :: high_resolution_clock)

Nar*_*rek 12 c++ android android-ndk c++-chrono

下面的代码不打印纪元.

typedef std::chrono::high_resolution_clock Clock;
typedef std::chrono::milliseconds Milliseconds;
auto res = std::chrono::duration_cast<Milliseconds>(Clock::now().time_since_epoch()).count();
std::stringstream ss;
ss << res;
printf(">>>>>>>>>>> TimeUtiles::getTimestamp %s", ss.str().c_str());
Run Code Online (Sandbox Code Playgroud)

我使用NDK r9d并选择了NDK工具链版本为4.8!

编辑:

std::chrono::high_resolution_clockstd::chrono::system_clock和它的工作.为什么?

How*_*ant 6

system_clock就像一块手表(在智能手机接管地球之前你的手腕上的东西).它可以告诉你一天中的时间.并且因为没有时钟保持完美的时间,它有时会询问另一个时钟的时间,并对其自身进行微小调整以保持准确.

steady_clock就像一块秒表.这对于在跑道上计时跑步者或计时功能非常有用.它从不调整自己,但努力尽可能每秒标记一秒钟.但它不知道一天中的时间,甚至是一年中的哪一天.

high_resolution_clock也与任何人类日历或时间系统没有任何关系,并且被允许成为typedef任何一个system_clocksteady_clock.而在实践中,它始终是typedef这些时钟之一.

在您的系统上,high_resolution_clock显然是同一类型steady_clock.