While doing some benchmark testing on both Windows and Linux, the
results of the exact same code was reversed. A slight difference in
the percentages is understandable, but I fail to see why the results
would be reversed. Could someone shed some light on this issue?
First the benchmark results:
C:\TEMP>timestamp.pl
Rate Matt Ron
Matt 162840/s -- -37%
Ron 257003/s 58% --
[r...@099vicidial101 ~]# ./timestamp.pl
Rate Ron Matt
Ron 110132/s -- -29%
Matt 155763/s 41% --
The code:
#!/usr/bin/perl
use strict;
use warnings;
use POSIX qw(strftime);
use Benchmark qw(:all);
my $count = 1_000_000;
cmpthese($count, {
Matt => \&matt,
Ron => \&ron,
});
sub matt {
my $now_date_epoch = time();
my $BDtarget = ($now_date_epoch - 5);
my ($Bsec,$Bmin,$Bhour,$Bmday,$Bmon,$Byear,$Bwday,$Byday,$Bisdst)
= localtime($BDtarget);
$Byear = ($Byear + 1900);
$Bmon++;
if ($Bmon < 10) {$Bmon = "0$Bmon";}
if ($Bmday < 10) {$Bmday = "0$Bmday";}
if ($Bhour < 10) {$Bhour = "0$Bhour";}
if ($Bmin < 10) {$Bmin = "0$Bmin";}
if ($Bsec < 10) {$Bsec = "0$Bsec";}
my $BDtsSQLdate = "$Byear$Bmon$Bmday$Bhour$Bmin$Bsec";
}
sub ron {
my $BDtsSQLdate = strftime("%Y%m%d%H%M%S", localtime(time() -
5) );
}
--
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]
http://learn.perl.org/