diff options
author | Gerald Combs <gerald@wireshark.org> | 2016-04-07 15:31:21 -0700 |
---|---|---|
committer | Michael Mann <mmann78@netscape.net> | 2016-07-30 16:29:36 +0000 |
commit | 183d7f3b78de30581390244a72c6ab328e6338f0 (patch) | |
tree | 9071a421aa28bfe201a06718b855cd2659a6398b /wsutil/time_util.c | |
parent | 852a56139e6c0c3ea4b844c6837cb13db339e1b3 (diff) | |
download | wireshark-183d7f3b78de30581390244a72c6ab328e6338f0.tar.gz |
Add string function times to wmem_test.
The system, GLib, and wmem string functions can perform differently,
particularly on Windows. Start adding performance tests to wmem_test so
that we can see the differences.
With this change applied "wmem_test --verbose" prints out the following
on a Windows 7 x64 VM here. wmem_test is linked against GLib 2.4.20.
(MINPERF:g_printf_string_upper_bound (via g_snprintf) 1 string: u 327.602 ms s 0
.000 ms)
(MINPERF:g_printf_string_upper_bound (via g_snprintf) 5 strings: u 1419.609 ms s
0.000 ms)
(MINPERF:g_printf_string_upper_bound (via g_snprintf) mixed args: u 1606.810 ms
s 0.000 ms)
(MINPERF:_snprintf_s upper bound 1 string: u 124.801 ms s 0.000 ms)
(MINPERF:_snprintf_s upper bound 5 strings: u 140.401 ms s 0.000 ms)
(MINPERF:_snprintf_s upper bound mixed args: u 124.801 ms s 0.000 ms)
(MINPERF:g_strdup_printf 2 strings: u 702.005 ms s 0.156 ms)
(MINPERF:g_strconcat 2 strings: u 78.000 ms s 0.000 ms)
(MINPERF:g_strdup_printf 5 strings: u 1419.609 ms s 0.156 ms)
(MINPERF:g_strconcat 5 strings: u 93.601 ms s 0.156 ms)
(MINPERF:wmem_strdup_printf 2 strings: u 343.202 ms s 0.312 ms)
(MINPERF:wmem_strconcat 2 strings: u 93.601 ms s 0.468 ms)
(MINPERF:wmem_strdup_printf 5 strings: u 327.602 ms s 8.268 ms)
(MINPERF:wmem_strconcat 5 strings: u 62.400 ms s 3.432 ms)
Change-Id: Id9b23918829db1719d141e7f830b9eba6245a25b
Reviewed-on: https://code.wireshark.org/review/14857
Reviewed-by: Gerald Combs <gerald@wireshark.org>
Petri-Dish: Gerald Combs <gerald@wireshark.org>
Tested-by: Petri Dish Buildbot <buildbot-no-reply@wireshark.org>
Reviewed-by: Michael Mann <mmann78@netscape.net>
Diffstat (limited to 'wsutil/time_util.c')
-rw-r--r-- | wsutil/time_util.c | 30 |
1 files changed, 17 insertions, 13 deletions
diff --git a/wsutil/time_util.c b/wsutil/time_util.c index cf209bfbb3..66b78bb054 100644 --- a/wsutil/time_util.c +++ b/wsutil/time_util.c @@ -72,22 +72,14 @@ mktime_utc(struct tm *tm) #endif /* !HAVE_TIMEGM */ } -static double last_utime = 0.0; -static double last_stime = 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; - +void get_resource_usage(double *utime, double *stime) { #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); + *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); #else /* _WIN32 */ HANDLE h_proc = GetCurrentProcess(); FILETIME cft, eft, kft, uft; @@ -97,11 +89,23 @@ void log_resource_usage(gboolean reset_delta, const char *format, ...) { uli_time.LowPart = uft.dwLowDateTime; uli_time.HighPart = uft.dwHighDateTime; - utime = uli_time.QuadPart / 10000000.0; + *utime = uli_time.QuadPart / 10000000.0; uli_time.LowPart = kft.dwLowDateTime; uli_time.HighPart = kft.dwHighDateTime; - stime = uli_time.QuadPart / 1000000000.0; + *stime = uli_time.QuadPart / 1000000000.0; #endif /* _WIN32 */ +} + +static double last_utime = 0.0; +static double last_stime = 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; + + get_resource_usage(&utime, &stime); if (reset_delta || last_utime == 0.0) { last_utime = utime; |