Home > Enterprise >  What the value of "chrono::steady_clock::now().time_since_epoch().count()" represents?
What the value of "chrono::steady_clock::now().time_since_epoch().count()" represents?

Time:02-08

cout << chrono::steady_clock::now().time_since_epoch().count() << "\n"; // it prints a 14-digit value

Is is the number of nanoseconds passed since 1970?

CodePudding user response:

Is is the number of nanoseconds passed since 1970?

Very unlikely.

It is the number of some duration unit passed since some time. Neither the unit nor the epoch is standardized.

This may not sound useful, and a single reading of std::chrono::steady_clock::now() arguably isn't very useful. (Beyond, say, seeding a random number generator perhaps)

steady_clock readings are intended to be compared against other steady_clock readings. It is useful for measuring elapsed time.

The count() is only useful if you cast the duration to a known duration period.

  •  Tags:  
  • Related