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.
This commit is contained in:
Adam Sutton 2013-09-03 23:14:31 +01:00
parent 84677dd6c1
commit 709f86057d

View file

@ -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++) {