| Summary: | usage of `date ` in apache2splitlogfile | ||
|---|---|---|---|
| Product: | Gentoo Linux | Reporter: | Philipp Gaschuetz <philipp> |
| Component: | [OLD] Server | Assignee: | Apache Team - Bugzilla Reports <apache-bugs> |
| Status: | RESOLVED FIXED | ||
| Severity: | enhancement | CC: | magnet |
| Priority: | High | ||
| Version: | unspecified | ||
| Hardware: | All | ||
| OS: | All | ||
| Whiteboard: | |||
| Package list: | Runtime testing required: | --- | |
| Attachments: | replaced usage of date with strftime | ||
Please supply a patch. Created attachment 33177 [details, diff]
replaced usage of date with strftime
btw: the same patch can be applied to apachesplitlogfile (ie. the 1.3 apache version) Added thanks. |
apache2splitlogfile and apachesplitlogfile use $date=`date +%Y-%m`; chop $date; $filename="$logs/VLOG-$date-${vhost}.log"; in order to get the current date for making up a filename. Is there any reason for not using use POSIX qw(strftime); $filename=strftime("$logs/VLOG-%Y-%m-${vhost}.log",localtime); instead? running the following test code: === use POSIX qw(strftime); $logs="/var/log/apache2"; $vhost="test.com"; $i=1; while($i++<10000) { $filename=strftime("$logs/VLOG-%Y-%m-${vhost}.log",localtime); #$date=`date +%Y-%m`; #chop $date; #$filename="$logs/VLOG-$date-${vhost}.log"; } === produces a hughe difference in timing: srv1 root # time perl test.pl <-- using strftime real 0m0.106s user 0m0.100s sys 0m0.010s srv1 root # time perl test2.pl <-- using date real 0m12.897s user 0m5.050s sys 0m8.720s Reproducible: Always Steps to Reproduce: 1. 2. 3.