Gentoo Websites Logo
Go to: Gentoo Home Documentation Forums Lists Bugs Planet Store Wiki Get Gentoo!

Bug 53350

Summary: usage of `date ` in apache2splitlogfile
Product: Gentoo Linux Reporter: Philipp Gaschuetz <philipp>
Component: [OLD] ServerAssignee: 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

Description Philipp Gaschuetz 2004-06-08 14:14:29 UTC
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.
Comment 1 Chuck Short (RETIRED) gentoo-dev 2004-06-12 19:33:26 UTC
Please supply a patch.
Comment 2 Philipp Gaschuetz 2004-06-13 09:03:27 UTC
Created attachment 33177 [details, diff]
replaced usage of date with strftime
Comment 3 Philipp Gaschuetz 2004-06-13 09:05:10 UTC
btw: the same patch can be applied to apachesplitlogfile (ie. the 1.3 apache version)
Comment 4 Chuck Short (RETIRED) gentoo-dev 2004-06-13 19:27:57 UTC
Added thanks.