use Benchmark; sub xor_swap { my($num1x,$num2x) = @_; $num1x ^= $num2x; $num2x ^= $num1x; $num1x ^= $num2x; } sub perl_swap { my($num1x,$num2x) = @_; ($num1x,$num2x)=($num2x,$num1x); } timethese (1_000_000, { xor_swap => sub { xor_swap(38,970); }, perl_swap => sub { perl_swap(38,970); } });
Results:
Benchmark: timing 1000000 iterations of perl_swap, xor_swap... perl_swap: 5 wallclock secs ( 4.87 usr + 0.00 sys = 4.87 CPU) @ 205338.81/s (n=1000000) xor_swap: 4 wallclock secs ( 4.23 usr + 0.00 sys = 4.23 CPU) @ 236406.62/s (n=1000000)
In reply to Re^3: Extraction of List of Coordinates
by sgifford
in thread Extraction of List of Coordinates
by EchoAngel
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |