aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--wsutil/time_util.c29
1 files changed, 15 insertions, 14 deletions
diff --git a/wsutil/time_util.c b/wsutil/time_util.c
index 66b78bb054..876d610368 100644
--- a/wsutil/time_util.c
+++ b/wsutil/time_util.c
@@ -72,14 +72,14 @@ mktime_utc(struct tm *tm)
#endif /* !HAVE_TIMEGM */
}
-void get_resource_usage(double *utime, double *stime) {
+void get_resource_usage(double *user_time, double *sys_time) {
#ifndef _WIN32
struct rusage ru;
getrusage(RUSAGE_SELF, &ru);
- *utime = ru.ru_utime.tv_sec + (ru.ru_utime.tv_usec / 1000000.0);
- *stime = ru.ru_stime.tv_sec + (ru.ru_stime.tv_usec / 1000000.0);
+ *user_time = ru.ru_utime.tv_sec + (ru.ru_utime.tv_usec / 1000000.0);
+ *sys_time = ru.ru_stime.tv_sec + (ru.ru_stime.tv_usec / 1000000.0);
#else /* _WIN32 */
HANDLE h_proc = GetCurrentProcess();
FILETIME cft, eft, kft, uft;
@@ -89,31 +89,32 @@ void get_resource_usage(double *utime, double *stime) {
uli_time.LowPart = uft.dwLowDateTime;
uli_time.HighPart = uft.dwHighDateTime;
- *utime = uli_time.QuadPart / 10000000.0;
+ *user_time = uli_time.QuadPart / 10000000.0;
uli_time.LowPart = kft.dwLowDateTime;
uli_time.HighPart = kft.dwHighDateTime;
- *stime = uli_time.QuadPart / 1000000000.0;
+ *sys_time = uli_time.QuadPart / 1000000000.0;
#endif /* _WIN32 */
}
-static double last_utime = 0.0;
-static double last_stime = 0.0;
+static double last_user_time = 0.0;
+static double last_sys_time = 0.0;
void log_resource_usage(gboolean reset_delta, const char *format, ...) {
va_list ap;
GString *log_str = g_string_new("");
- double utime;
- double stime;
+ double user_time;
+ double sys_time;
- get_resource_usage(&utime, &stime);
+ get_resource_usage(&user_time, &sys_time);
- if (reset_delta || last_utime == 0.0) {
- last_utime = utime;
- last_stime = stime;
+ if (reset_delta || last_user_time == 0.0) {
+ last_user_time = user_time;
+ last_sys_time = sys_time;
}
g_string_append_printf(log_str, "user %.3f +%.3f sys %.3f +%.3f ",
- utime, utime - last_utime, stime, stime - last_stime);
+ user_time, user_time - last_user_time,
+ sys_time, sys_time - last_sys_time);
va_start(ap, format);
g_string_append_vprintf(log_str, format, ap);