1
0

timestamp.h 379 B

123456789101112131415161718192021
  1. #ifndef _INCLUDE_TIME_STAMP_HPP
  2. #define _INCLUDE_TIME_STAMP_HPP
  3. #include <sys/timeb.h>
  4. #ifndef WIN32
  5. #include <sys/time.h>
  6. #endif
  7. struct TIME{
  8. static uint64_t getMilliseconds()
  9. {
  10. #ifndef WIN32
  11. struct timeval tv;
  12. ::gettimeofday(&tv, 0);
  13. return tv.tv_sec*1000+tv.tv_usec/1000;
  14. #else
  15. struct timeb tb;
  16. ::ftime(&tb);
  17. return tb.time*1000+tb.millitm;
  18. #endif
  19. }
  20. };
  21. #endif