From 709f86057db2cba4e723730567ee1bd1244cf21e Mon Sep 17 00:00:00 2001 From: Adam Sutton Date: Tue, 3 Sep 2013 23:14:31 +0100 Subject: [PATCH] tvhlog: performance improvement when trace/debug is disabled. The processing performed in the hexdump routine, commonly used in SI table trace output. Was having a significant impact on performance as it was not pre-processing the config to see if trace was even enabled before continuing to build up the (large and frequent) hex strings. --- src/tvhlog.c | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/src/tvhlog.c b/src/tvhlog.c index fca5c0c7..219cacaa 100644 --- a/src/tvhlog.c +++ b/src/tvhlog.c @@ -243,7 +243,7 @@ void tvhlogv ( const char *file, int line, int ok, options; size_t l; char buf[1024]; - + /* Check debug enabled (and cache config) */ pthread_mutex_lock(&tvhlog_mutex); options = tvhlog_options; @@ -319,9 +319,16 @@ _tvhlog_hexdump(const char *file, int line, const char *subsys, const uint8_t *data, ssize_t len ) { - int i, c; + int i, c, skip; char str[1024]; + /* Don't process if trace is OFF */ + pthread_mutex_lock(&tvhlog_mutex); + skip = (severity > tvhlog_level); + pthread_mutex_unlock(&tvhlog_mutex); + if (skip) return; + + /* Build and log output */ while (len > 0) { c = 0; for (i = 0; i < HEXDUMP_WIDTH; i++) {