Help for this page

Select Code to Download


  1. or download this
    sub using_str_bit_ops_and_s {
       my ($s1, $s2) = @_;
       (my $mask = $s1) =~ tr/\x00/\xFF/c;
       return ($s1 & $mask) | ($s2 & ~$mask);
    }
    
  2. or download this
    sub using_str_bit_xor {
       my ($s1, $s2) = @_;
       (my $mask = $s1) =~ tr/\x00/\xFF/c;
       return (($s1 ^ $s2) & $mask ) ^ $s2;
    }
    
  3. or download this
    my $x = pack 'C*', map int rand(256), 1 .. 64*1024;
    my $y = pack 'C*', map int rand(256), 1 .. 64*1024;
    ...
      using_str_bit_ops_and_s => sub{ my $r = using_str_bit_ops_and_s($x, 
    +$y) },
      using_str_bit_xor=> sub{ my $r = using_str_bit_xor($x, $y) },
    };
    
  4. or download this
                             Rate using_str_bit_ops_and_s       using_str_
    +bit_xor
    using_str_bit_ops_and_s 686/s                      --                 
    +   -16%
    using_str_bit_xor       821/s                     20%                 
    +     --