From 5ec739c712003574faf7acc188223c9f745a5f8d Mon Sep 17 00:00:00 2001 From: Jeremy Lakeman Date: Wed, 25 Jul 2012 12:14:53 +0930 Subject: [PATCH] Add performance timing debug option --- commandline.c | 4 ++-- log.c | 2 ++ overlay.c | 12 +++++++----- serval.h | 1 + 4 files changed, 12 insertions(+), 7 deletions(-) diff --git a/commandline.c b/commandline.c index 57727802..c20d1ad5 100644 --- a/commandline.c +++ b/commandline.c @@ -289,8 +289,8 @@ int parseCommandLine(const char *argv0, int argc, const char *const *args) /* clean up after ourselves */ overlay_mdp_client_done(); OUT(); - //TODO debug flag for method profiling - if (1) + + if (debug&DEBUG_TIMING) fd_showstats(); return result; } diff --git a/log.c b/log.c index 4128d7e6..f4abc32c 100644 --- a/log.c +++ b/log.c @@ -246,6 +246,8 @@ unsigned int debugFlagMask(const char *flagname) { else if (!strcasecmp(flagname,"broadcasts")) return DEBUG_BROADCASTS; else if (!strcasecmp(flagname,"manifests")) return DEBUG_MANIFESTS; else if (!strcasecmp(flagname,"mdprequests")) return DEBUG_MDPREQUESTS; + else if (!strcasecmp(flagname,"timing")) return DEBUG_TIMING; + return 0; } diff --git a/overlay.c b/overlay.c index d95fc55d..0548e9ca 100644 --- a/overlay.c +++ b/overlay.c @@ -128,9 +128,9 @@ int overlayServerMode() /* Create structures to use 1MB of RAM for testing */ overlay_route_init(1); -#define SCHEDULE(X, Y, D) \ -struct sched_ent _sched_##X; \ -struct profile_total _stats_##X; \ +#define SCHEDULE(X, Y, D) { \ +static struct sched_ent _sched_##X; \ +static struct profile_total _stats_##X; \ bzero(&_sched_##X, sizeof(struct sched_ent)); \ bzero(&_stats_##X, sizeof(struct profile_total)); \ _sched_##X.stats = &_stats_##X; \ @@ -138,7 +138,7 @@ _sched_##X.function=X;\ _stats_##X.name="" #X "";\ _sched_##X.alarm=overlay_gettime_ms()+Y;\ _sched_##X.deadline=_sched_##X.alarm+D;\ -schedule(&_sched_##X); +schedule(&_sched_##X); } /* Periodically check for server shut down */ SCHEDULE(server_shutdown_check, 0, 100); @@ -163,7 +163,9 @@ schedule(&_sched_##X); SCHEDULE(overlay_route_tick, 100, 100); /* Show CPU usage stats periodically */ - SCHEDULE(fd_periodicstats, 3000, 500); + if (debug&DEBUG_TIMING){ + SCHEDULE(fd_periodicstats, 3000, 500); + } #undef SCHEDULE diff --git a/serval.h b/serval.h index 8496c7e6..6a29420f 100644 --- a/serval.h +++ b/serval.h @@ -1123,6 +1123,7 @@ int overlay_saw_mdp_containing_frame(overlay_frame *f,long long now); #define DEBUG_PACKETCONSTRUCTION (1 << 23) #define DEBUG_MANIFESTS (1 << 24) #define DEBUG_MDPREQUESTS (1 << 25) +#define DEBUG_TIMING (1 << 26) /* bitmask values for monitor_tell_clients */ #define MONITOR_VOMP (1<<0)