if ( $sUnpackedCDPcap ne $sPhoneCapabilityCode
& $sUnpackedCDPcap ne $s3905CapabilityCode )
{
##Do some stuff##
}
####
if ( ($sUnpackedCDPcap != $sPhoneCapabilityCode) &&
($sUnpackedCDPcap != $s3905CapabilityCode ) )
{
##Do some stuff##
}
####
#!usr/bin/perl
use strict;
use warnings;
use Benchmark qw(:all);
my $count = 100000000; # one hundred million cycles
my $sUnpackedCDPcap = "00000491";
my $sPhoneCapabilityCode = "00000490";
my $s3905CapabilityCode ="00000290";
timethese
($count,
{
'String_if' => \&string_if,
'Do_Nothing' => \&do_nothing,
'Numeric_if' => \&numeric_if,
}
);
sub do_nothing
{
#don't do anything
return;
}
sub string_if
{
#$sUnpackedCDPcap is Dynamically generated during the program
if ($sUnpackedCDPcap ne $sPhoneCapabilityCode &
$sUnpackedCDPcap ne $s3905CapabilityCode )
{
##Do some stuff##
}
return;
}
sub numeric_if
{
if ( ( $sUnpackedCDPcap != $sPhoneCapabilityCode) &&
( $sUnpackedCDPcap != $s3905CapabilityCode ) )
{
##Do some stuff##
}
return;
}
__END__
Benchmark: timing 100000000 iterations of Do_Nothing, Numeric_if, String_if...
Do_Nothing: 4 wallclock secs ( 4.03 usr + 0.00 sys = 4.03 CPU) @ 24801587.30/s (n=100000000)
Numeric_if: 15 wallclock secs (16.44 usr + 0.00 sys = 16.44 CPU) @ 6083835.25/s (n=100000000)
String_if: 25 wallclock secs (26.59 usr + 0.00 sys = 26.59 CPU) @ 3760388.07/s (n=100000000)