[dougb@scalar.org: Re: FW: SPUG: Perl IIS and Out of Memory error.]
Doug Beaver
dougb at scalar.org
Fri Oct 22 20:25:51 CDT 1999
Just realized that I only replied to Greg on this and not the list...
I also realized from William Julien's reply that strftime is also in the
POSIX module (I thought it was only in Date::Format). If you use the
strftime in POSIX, it's even faster than the time2str in Date::Format:
Benchmark: timing 10000 iterations of strftime, time2str...
strftime: 1 wallclock secs ( 1.38 usr + 0.03 sys = 1.41 CPU)
time2str: 3 wallclock secs ( 2.56 usr + 0.02 sys = 2.59 CPU)
Only thing is, I'm pretty sure that NT doesn't have a full POSIX
implementation, so maybe Greg should try Date::Format if he was using
the POSIX version of strftime before, it could be that there's a bug in
NT's implementation. I've never used perl on NT before, so I am
completely clueless in this regard, someone please speak up if they have
more accurate info or a better idea...
Doug
----- Forwarded message from Doug Beaver <dougb at scalar.org> -----
Date: Fri, 22 Oct 1999 14:37:32 -0700
From: Doug Beaver <dougb at scalar.org>
To: "Padden, Greg" <Greg.Padden at metrokc.gov>
Subject: Re: FW: SPUG: Perl IIS and Out of Memory error.
X-Mailer: Mutt 0.95.5i
In-Reply-To: <DB6E9478EABDD211BBCF00805FA7E0E2014E5C8C at kcmail1.metrokc.gov>; from Padden, Greg on Fri, Oct 22, 1999 at 01:00:37PM -0700
On Fri, Oct 22, 1999 at 01:00:37PM -0700, Padden, Greg wrote:
>
> I found that the line:
> my $date = strftime('%D',localtime);
>
> Is causing the problem.
You should check your error logs, perl should be saying something like:
Type of arg 2 to Date::Format::strftime must be array (not localtime) at
/home/dougb/strftime line 3, near "localtime)"
The reason is that strftime has a prototype on it that requires an
array, you have to do this:
my @lt = localtime;
my $date = strftime('%d', localtime);
A better solution would to skip strftime altogether and use time2str,
it's faster:
my $date = time2str('%d', time);
Benchmarks included below:
% perl
use strict;
use Benchmark;
use Date::Format;
my $count = shift || 10000;
timethese($count, {
'time2str' => sub {
my $date = time2str('%d', time);
},
'strftime' => sub {
my @lt = localtime;
my $date = strftime('%d', @lt);
}
});
<ctrl-d>
Benchmark: timing 10000 iterations of strftime, time2str...
strftime: 5 wallclock secs ( 5.90 usr + 0.05 sys = 5.95 CPU)
time2str: 3 wallclock secs ( 2.54 usr + 0.08 sys = 2.62 CPU)
Doug
--
Smithers: I'm afraid we have a bad image, Sir. Market research shows
people see you as somewhat of an ogre.
Burns: I ought to club them and eat their bones!
----- End forwarded message -----
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
POST TO: spug-list at pm.org PROBLEMS: owner-spug-list at pm.org
Seattle Perl Users Group (SPUG) Home Page: http://www.halcyon.com/spug/
SUBSCRIBE/UNSUBSCRIBE: Replace ACTION below by subscribe or unsubscribe
Email to majordomo at pm.org: ACTION spug-list your_address
More information about the spug-list
mailing list