diff options
author | Nat Goodspeed <nat@lindenlab.com> | 2024-05-15 12:18:31 -0400 |
---|---|---|
committer | Nat Goodspeed <nat@lindenlab.com> | 2024-05-15 12:18:31 -0400 |
commit | 7ccf02515ad3f9e3bf795d651fe4b3c0d773f353 (patch) | |
tree | c4adc897c07f652e617e91fbf41c12b823acc808 /indra/llcommon/llprocinfo.cpp | |
parent | 1abf5f18d6afc7ae9e1b1562b92e5c1ce33b722f (diff) | |
parent | e7eced3c87310b15ac20cc3cd470d67686104a14 (diff) |
Merge commit 'e7eced3' into lua-timers for whitespace fixes.
Diffstat (limited to 'indra/llcommon/llprocinfo.cpp')
-rw-r--r-- | indra/llcommon/llprocinfo.cpp | 64 |
1 files changed, 32 insertions, 32 deletions
diff --git a/indra/llcommon/llprocinfo.cpp b/indra/llcommon/llprocinfo.cpp index c00f979b0b..69be00e14a 100644 --- a/indra/llcommon/llprocinfo.cpp +++ b/indra/llcommon/llprocinfo.cpp @@ -1,4 +1,4 @@ -/** +/** * @file llprocinfo.cpp * @brief Process, cpu and resource usage information APIs. * @author monty@lindenlab.com @@ -30,7 +30,7 @@ #if LL_WINDOWS -#define PSAPI_VERSION 1 +#define PSAPI_VERSION 1 #include "windows.h" #include "psapi.h" @@ -38,7 +38,7 @@ #include <sys/resource.h> #include <mach/mach.h> - + #else #include <sys/time.h> @@ -52,42 +52,42 @@ void LLProcInfo::getCPUUsage(time_type & user_time, time_type & system_time) { #if LL_WINDOWS - HANDLE self(GetCurrentProcess()); // Does not have to be closed - FILETIME ft_dummy, ft_system, ft_user; - - GetProcessTimes(self, &ft_dummy, &ft_dummy, &ft_system, &ft_user); - ULARGE_INTEGER uli; - uli.u.LowPart = ft_system.dwLowDateTime; - uli.u.HighPart = ft_system.dwHighDateTime; - system_time = uli.QuadPart / U64L(10); // Convert to uS - uli.u.LowPart = ft_user.dwLowDateTime; - uli.u.HighPart = ft_user.dwHighDateTime; - user_time = uli.QuadPart / U64L(10); - + HANDLE self(GetCurrentProcess()); // Does not have to be closed + FILETIME ft_dummy, ft_system, ft_user; + + GetProcessTimes(self, &ft_dummy, &ft_dummy, &ft_system, &ft_user); + ULARGE_INTEGER uli; + uli.u.LowPart = ft_system.dwLowDateTime; + uli.u.HighPart = ft_system.dwHighDateTime; + system_time = uli.QuadPart / U64L(10); // Convert to uS + uli.u.LowPart = ft_user.dwLowDateTime; + uli.u.HighPart = ft_user.dwHighDateTime; + user_time = uli.QuadPart / U64L(10); + #elif LL_DARWIN - struct rusage usage; + struct rusage usage; - if (getrusage(RUSAGE_SELF, &usage)) - { - user_time = system_time = time_type(0U); - return; - } - user_time = U64(usage.ru_utime.tv_sec) * U64L(1000000) + usage.ru_utime.tv_usec; - system_time = U64(usage.ru_stime.tv_sec) * U64L(1000000) + usage.ru_stime.tv_usec; + if (getrusage(RUSAGE_SELF, &usage)) + { + user_time = system_time = time_type(0U); + return; + } + user_time = U64(usage.ru_utime.tv_sec) * U64L(1000000) + usage.ru_utime.tv_usec; + system_time = U64(usage.ru_stime.tv_sec) * U64L(1000000) + usage.ru_stime.tv_usec; #else // Linux - struct rusage usage; + struct rusage usage; + + if (getrusage(RUSAGE_SELF, &usage)) + { + user_time = system_time = time_type(0U); + return; + } + user_time = U64(usage.ru_utime.tv_sec) * U64L(1000000) + usage.ru_utime.tv_usec; + system_time = U64(usage.ru_stime.tv_sec) * U64L(1000000) + usage.ru_stime.tv_usec; - if (getrusage(RUSAGE_SELF, &usage)) - { - user_time = system_time = time_type(0U); - return; - } - user_time = U64(usage.ru_utime.tv_sec) * U64L(1000000) + usage.ru_utime.tv_usec; - system_time = U64(usage.ru_stime.tv_sec) * U64L(1000000) + usage.ru_stime.tv_usec; - #endif // LL_WINDOWS/LL_DARWIN/Linux } |