fix vs time

This commit is contained in:
sunsuodong 2021-09-02 21:45:25 +08:00
parent 790bfeb292
commit ed3c85c2e9
1 changed files with 7 additions and 6 deletions

View File

@ -28,12 +28,13 @@ namespace mindspore {
namespace lite { namespace lite {
uint64_t GetTimeUs() { uint64_t GetTimeUs() {
#ifdef SUPPORT_MSVC #ifdef SUPPORT_MSVC
FILETIME ft; const int sec_to_us = 1000000;
LARGE_INTEGER li; LARGE_INTEGER cur_time, frequency;
GetSystemTimeAsFileTime(&ft); QueryPerformanceCounter(&cur_time);
li.LowPart = ft.dwLowDateTime; QueryPerformanceFrequency(&frequency);
li.HighPart = ft.dwHighDateTime; uint64_t sec = cur_time.QuadPart / frequency.QuadPart;
return li.QuadPart * 100; uint64_t usec = (cur_time.QuadPart % frequency.QuadPart) * sec_to_us / frequency.QuadPart;
return sec * sec_to_us + usec;
#else #else
struct timespec ts = {0, 0}; struct timespec ts = {0, 0};
if (clock_gettime(CLOCK_MONOTONIC, &ts) != 0) { if (clock_gettime(CLOCK_MONOTONIC, &ts) != 0) {