Yeah there might be some swapping but no direct files. I converted the benchmark (code below) to use timethese(5) to do some repeating.
Weak machine:
Benchmark: timing 5 iterations of FastMktime::caching_mktime, POSIX::m
+ktime, TIME::Local::timegm_nocheck...
FastMktime::caching_mktime: 120 wallclock secs (120.21 usr + 0.05 sys
+ = 120.26 CPU) @ 0.04/s (n=5)
POSIX::mktime: 360 wallclock secs (165.42 usr + 193.81 sys = 359.23 CP
+U) @ 0.01/s (n=5)
TIME::Local::timegm_nocheck: 293 wallclock secs (292.72 usr + 0.14 sy
+s = 292.86 CPU) @ 0.02/s (n=5)
stronger machine:
Benchmark: timing 5 iterations of FastMktime::caching_mktime, POSIX::m
+ktime, TIME::Local::timegm_nocheck...
FastMktime::caching_mktime: 65 wallclock secs (64.77 usr + 0.02 sys =
+ 64.79 CPU) @ 0.08/s (n=5)
POSIX::mktime: 118 wallclock secs (58.16 usr + 60.47 sys = 118.63 CPU)
+ @ 0.04/s (n=5)
TIME::Local::timegm_nocheck: 143 wallclock secs (143.07 usr + 0.54 sy
+s = 143.61 CPU) @ 0.03/s (n=5)
benchmark.t
#!/usr/bin/perl
use FastMktime;
use Benchmark qw(:all);
use POSIX qw(mktime);
use Time::Local;
my $sstart = time;
my $sstop = $sstart + 1e7;
my @dates;
# Stuff 1e7 sequential datestamps into an array.
for (my $s=$sstart; $s<$sstop; $s++) {
push(@dates, [ (gmtime $s)[0..5] ]);
}
my $tmp;
my $results = timethese(1, {
'POSIX::mktime' => sub { $tmp = POSIX::mktime(@$_) for @dates },
'TIME::Local::timegm_nocheck' => sub { $tmp = Time::Local::timegm_
+nocheck(@$_) for @dates },
'FastMktime::caching_mktime' => sub { $tmp = FastMktime::caching_m
+ktime(@$_) for @dates },
});
-
Are you posting in the right place? Check out Where do I post X? to know for sure.
-
Posts may use any of the Perl Monks Approved HTML tags. Currently these include the following:
<code> <a> <b> <big>
<blockquote> <br /> <dd>
<dl> <dt> <em> <font>
<h1> <h2> <h3> <h4>
<h5> <h6> <hr /> <i>
<li> <nbsp> <ol> <p>
<small> <strike> <strong>
<sub> <sup> <table>
<td> <th> <tr> <tt>
<u> <ul>
-
Snippets of code should be wrapped in
<code> tags not
<pre> tags. In fact, <pre>
tags should generally be avoided. If they must
be used, extreme care should be
taken to ensure that their contents do not
have long lines (<70 chars), in order to prevent
horizontal scrolling (and possible janitor
intervention).
-
Want more info? How to link
or How to display code and escape characters
are good places to start.