]> git.ipfire.org Git - thirdparty/haproxy.git/commit
CONTRIB: halog: avoid calling time/localtime/mktime for each line
authorWilly Tarreau <w@1wt.eu>
Fri, 23 May 2014 14:36:56 +0000 (16:36 +0200)
committerWilly Tarreau <w@1wt.eu>
Fri, 23 May 2014 14:40:25 +0000 (16:40 +0200)
commit9f66aa9cc40d5cc5405b23ddc100068474252fb4
tree25923ba892fda12872381b55fe0cecf45fbf7633
parente97b9048016977feceb2b21f14a6e5cfea34d295
CONTRIB: halog: avoid calling time/localtime/mktime for each line

The last commit provides time-based filtering. Unfortunately, it wastes
90% of the time calling the expensive time()/localtime()/mktime()
functions.

This patch does 3 things :
  - call time()/localtime() only once to initialize the correct
    struct timeinfo ;

  - call mktime() only when the time has changed regardless of
    the current second.

  - manually add the current second to the cached result.

Doing just this is enough to multiply the parsing speed by 8.
contrib/halog/halog.c