6 ms·
Parsing time is a huge cost when the Logfile Navigator (http://lnav.org http://lnav.org) is parsing log files. The libc strptime() is terribly slow, so I wrote
by tstack 10y ago
Parsing time is a huge cost when the Logfile Navigator (http://lnav.org http://lnav.org) is parsing log files. The libc strptime() is terribly slow, so I wrote a simple compiler[1] that would spit out inlined C++ code for parsing a particular time format (e.g. "%Y-%m-%dT%H:%M:%S.%f%z"). Coupled with the fact that a time format is not going to differ across log lines in a single file, lnav is able to lock onto a date format and parse all the lines in a file fairly quickly.
[1] - https://github.com/tstack/lnav/blob/master/src/ptimec.cc https://github.com/tstack/lnav/blob/master/src/ptimec.cc