From 798b1b3431ccf345a93bd01413a64d272e530c6c Mon Sep 17 00:00:00 2001 From: Christian Grothoff Date: Tue, 23 Oct 2012 18:42:46 +0000 Subject: -add option to make expensive heap stat gathering optional --- configure.ac | 9 +++++++++ src/statistics/statistics_api.c | 2 ++ 2 files changed, 11 insertions(+) diff --git a/configure.ac b/configure.ac index 28a23f8f0..3caaf253a 100644 --- a/configure.ac +++ b/configure.ac @@ -999,6 +999,15 @@ AC_ARG_ENABLE([experimental], AC_MSG_RESULT($enable_experimental) AM_CONDITIONAL([HAVE_EXPERIMENTAL], [test "x$enable_experimental" = "xyes"]) +# should memory statistics be kept (very expensive CPU-wise!) +AC_MSG_CHECKING(whether to create expensive statistics on memory use) +AC_ARG_ENABLE([heapstats], + [AS_HELP_STRING([--enable-heapstats], [enable expensive heap statistics])], + [enable_heapstats=1], + [enable_heapstats=0]) +AC_MSG_RESULT($enable_heapstats) +AC_DEFINE_UNQUOTED([ENABLE_HEAP_STATISTICS],$enable_heapstats,[enable expensive heap statistics]) + # should code be enabled that works around missing OS functionality on Windows? # used for test cases if test $build_target = "mingw" diff --git a/src/statistics/statistics_api.c b/src/statistics/statistics_api.c index 79d9604c7..0f4149ead 100644 --- a/src/statistics/statistics_api.c +++ b/src/statistics/statistics_api.c @@ -271,6 +271,7 @@ struct GNUNET_STATISTICS_Handle static void update_memory_statistics (struct GNUNET_STATISTICS_Handle *h) { +#if ENABLE_HEAP_STATISTICS uint64_t current_heap_size = 0; uint64_t current_rss = 0; @@ -304,6 +305,7 @@ update_memory_statistics (struct GNUNET_STATISTICS_Handle *h) h->peak_rss = current_rss; GNUNET_STATISTICS_set (h, "# peak resident set size", current_rss, GNUNET_NO); } +#endif } -- cgit v1.2.3