From c7243650c18ec4317a0897e9b406193854955201 Mon Sep 17 00:00:00 2001 From: Pablo Neira Ayuso Date: Sun, 21 Dec 2008 20:19:46 +0100 Subject: cache_iterators: display the commit time taken in the logs This patch reports to the logfile the time taken to commit the entries. The output is expressed in seconds.microseconds. Signed-off-by: Pablo Neira Ayuso --- src/cache_iterators.c | 7 +++++++ 1 file changed, 7 insertions(+) (limited to 'src') diff --git a/src/cache_iterators.c b/src/cache_iterators.c index 8ad9612..a14f428 100644 --- a/src/cache_iterators.c +++ b/src/cache_iterators.c @@ -195,6 +195,7 @@ void cache_commit(struct cache *c) unsigned int commit_exist = c->stats.commit_exist; unsigned int commit_fail = c->stats.commit_fail; struct __commit_container tmp; + struct timeval commit_start, commit_stop, res; tmp.h = nfct_open(CONNTRACK, 0); if (tmp.h == NULL) { @@ -203,9 +204,12 @@ void cache_commit(struct cache *c) } tmp.c = c; + gettimeofday(&commit_start, NULL); /* commit master conntrack first, then related ones */ hashtable_iterate(c->h, &tmp, do_commit_master); hashtable_iterate(c->h, &tmp, do_commit_related); + gettimeofday(&commit_stop, NULL); + timersub(&commit_stop, &commit_start, &res); /* calculate new entries committed */ commit_ok = c->stats.commit_ok - commit_ok; @@ -222,6 +226,9 @@ void cache_commit(struct cache *c) dlog(LOG_NOTICE, "%u entries can't be " "committed", commit_fail); nfct_close(tmp.h); + + dlog(LOG_NOTICE, "commit has taken %llu.%06llu seconds", + res.tv_sec, res.tv_usec); } static int do_reset_timers(void *data1, void *data2) -- cgit v1.2.3