mirror of
https://github.com/shadps4-emu/shadPS4.git
synced 2025-08-04 00:13:08 +00:00
sceKernelGettimeofday: replace chrono by win32 api. Better performance
bb uses this function too much. Consuming almost 30% of cpu time
This commit is contained in:
parent
5b7ee037ac
commit
ed563e5717
@ -147,13 +147,20 @@ int PS4_SYSV_ABI sceKernelGettimeofday(OrbisKernelTimeval* tp) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
#ifdef _WIN64
|
#ifdef _WIN64
|
||||||
auto now = std::chrono::system_clock::now();
|
FILETIME filetime;
|
||||||
auto duration = now.time_since_epoch();
|
GetSystemTimeAsFileTime(&filetime);
|
||||||
auto seconds = std::chrono::duration_cast<std::chrono::seconds>(duration);
|
|
||||||
auto microsecs = std::chrono::duration_cast<std::chrono::microseconds>(duration - seconds);
|
|
||||||
|
|
||||||
tp->tv_sec = seconds.count();
|
constexpr u64 UNIX_TIME_START = 0x295E9648864000;
|
||||||
tp->tv_usec = microsecs.count();
|
constexpr u64 TICKS_PER_SECOND = 1000000;
|
||||||
|
|
||||||
|
u64 ticks = filetime.dwHighDateTime;
|
||||||
|
ticks <<= 32;
|
||||||
|
ticks |= filetime.dwLowDateTime;
|
||||||
|
ticks /= 10;
|
||||||
|
ticks -= UNIX_TIME_START;
|
||||||
|
|
||||||
|
tp->tv_sec = ticks / TICKS_PER_SECOND;
|
||||||
|
tp->tv_usec = ticks % TICKS_PER_SECOND;
|
||||||
#else
|
#else
|
||||||
timeval tv;
|
timeval tv;
|
||||||
gettimeofday(&tv, nullptr);
|
gettimeofday(&tv, nullptr);
|
||||||
|
Loading…
Reference in New Issue
Block a user