Skip to content

Instantly share code, notes, and snippets.

@sailfish009
Last active May 29, 2019 03:43
Show Gist options
  • Save sailfish009/c4b5ff2b6561ec2fb43748f03d1f28e9 to your computer and use it in GitHub Desktop.
Save sailfish009/c4b5ff2b6561ec2fb43748f03d1f28e9 to your computer and use it in GitHub Desktop.
#ifdef _WIN32
#include <chrono>
uint64_t milliseconds(void)
{
return std::chrono::duration_cast<std::chrono::milliseconds>
(std::chrono::steady_clock::now().time_since_epoch()).count();
}
#else
#include <sys/time.h>
uint64_t milliseconds(void)
{
struct timeval tv;
gettimeofday(&tv, NULL);
return (((uint64_t)tv.tv_sec * 1000) + ((uint64_t)tv.tv_usec / 1000));
}
#endif
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment