Are DateTime.Now and std::chrono::system_clock::now() the same?

Viewed 80

I am observing some weird problem.

I am subscribing to a WebSocket stream from both C++ and C#, and I am receiving the same event (they have the same sequence ID) with different times. I am stamping arrivalTime as soon as I receive a package.

I have this in C++:

auto arrivalTime = std::chrono::system_clock::now();

And have this in C#:

var arrivalTime = DateTime.Now;

And somehow, the C# one is 90% of the time earlier, from few microseconds up to 100ms, although sometimes the C++ one is earlier.

I know there can be some stuff going on my WebSocket libraries on C++ and C# and so on, but I'm just curious - should these 2 calls be the same if called at the same time?

0 Answers
Related