Gentoo Websites Logo
Go to: Gentoo Home Documentation Forums Lists Bugs Planet Store Wiki Get Gentoo!
Bug 53350 - usage of `date ` in apache2splitlogfile
Summary: usage of `date ` in apache2splitlogfile
Status: RESOLVED FIXED
Alias: None
Product: Gentoo Linux
Classification: Unclassified
Component: [OLD] Server (show other bugs)
Hardware: All All
: High enhancement (vote)
Assignee: Apache Team - Bugzilla Reports
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2004-06-08 14:14 UTC by Philipp Gaschuetz
Modified: 2004-06-13 19:27 UTC (History)
1 user (show)

See Also:
Package list:
Runtime testing required: ---


Attachments
replaced usage of date with strftime (patch,1.22 KB, patch)
2004-06-13 09:03 UTC, Philipp Gaschuetz
Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
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.