Udp
This commit is contained in:
committed by
Matthew McClaskey
parent
ba902f8194
commit
3b40a92548
34
common/network/webudp/WuClock.h
Normal file
34
common/network/webudp/WuClock.h
Normal file
@@ -0,0 +1,34 @@
|
||||
#pragma once
|
||||
#ifdef _WIN32
|
||||
#include <windows.h>
|
||||
#else
|
||||
#include <sys/time.h>
|
||||
#endif
|
||||
#include <stdint.h>
|
||||
|
||||
inline int64_t HpCounter() {
|
||||
#ifdef _WIN32
|
||||
LARGE_INTEGER li;
|
||||
QueryPerformanceCounter(&li);
|
||||
int64_t i64 = li.QuadPart;
|
||||
#else
|
||||
struct timeval t;
|
||||
gettimeofday(&t, 0);
|
||||
int64_t i64 = t.tv_sec * int64_t(1000000) + t.tv_usec;
|
||||
#endif
|
||||
return i64;
|
||||
}
|
||||
|
||||
inline int64_t HpFreq() {
|
||||
#ifdef _WIN32
|
||||
LARGE_INTEGER li;
|
||||
QueryPerformanceFrequency(&li);
|
||||
return li.QuadPart;
|
||||
#else
|
||||
return int64_t(1000000);
|
||||
#endif
|
||||
}
|
||||
|
||||
inline double MsNow() {
|
||||
return double(HpCounter()) * 1000.0 / double(HpFreq());
|
||||
}
|
||||
Reference in New Issue
Block a user