]> git.vpit.fr Git - perl/modules/Scalar-Vec-Util.git/commitdiff
Importing Scalar-Vec-Util-0.03.tar.gz v0.03
authorVincent Pit <vince@profvince.com>
Sun, 29 Jun 2008 16:15:08 +0000 (18:15 +0200)
committerVincent Pit <vince@profvince.com>
Sun, 29 Jun 2008 16:15:08 +0000 (18:15 +0200)
Changes
META.yml
README
lib/Scalar/Vec/Util.pm
samples/bench.pl

diff --git a/Changes b/Changes
index c8afa14cdb071375902d4ad209235d55594c8bb6..78cd7408f1785faa6f742bb3932fd65bca3445ef 100644 (file)
--- a/Changes
+++ b/Changes
@@ -1,5 +1,9 @@
 Revision history for Scalar-Vec-Util
 
 Revision history for Scalar-Vec-Util
 
+0.03    2008-06-01 12:30 UTC
+        + Chg : samples/bench.pl now compares with Bit::Vector when available.
+        + Doc : Show the benchmark.
+
 0.02    2008-05-13 16:40 UTC
         + Chg : Don't smoke this on 5.005 please.
         + Fix : File::Spec is a build dependency.
 0.02    2008-05-13 16:40 UTC
         + Chg : Don't smoke this on 5.005 please.
         + Fix : File::Spec is a build dependency.
index b2fb20003698de1771ccd5db73cb1b049d3ba2c9..27b65827704ec545fb5473cabd0013b84372f790 100644 (file)
--- a/META.yml
+++ b/META.yml
@@ -1,6 +1,6 @@
 --- #YAML:1.0
 name:                Scalar-Vec-Util
 --- #YAML:1.0
 name:                Scalar-Vec-Util
-version:             0.02
+version:             0.03
 abstract:            Utility routines for vec strings.
 license:             perl
 author:              
 abstract:            Utility routines for vec strings.
 license:             perl
 author:              
diff --git a/README b/README
index 69aa06bc0b036be56553a43c7ad6eaeb633381a2..ca8ba6bc9f083dde901208b6a0abdf73fe68dfe6 100644 (file)
--- a/README
+++ b/README
@@ -2,7 +2,7 @@ NAME
     Scalar::Vec::Util - Utility routines for vec strings.
 
 VERSION
     Scalar::Vec::Util - Utility routines for vec strings.
 
 VERSION
-    Version 0.02
+    Version 0.03
 
 SYNOPSIS
         use Scalar::Vec::Util qw/vfill vcopy veq/;
 
 SYNOPSIS
         use Scalar::Vec::Util qw/vfill vcopy veq/;
@@ -56,6 +56,37 @@ EXPORT
     The constants "SVU_PP" and "SVU_SIZE" are also only exported on request.
     They are all exported by the tags ':consts' and ':all'.
 
     The constants "SVU_PP" and "SVU_SIZE" are also only exported on request.
     They are all exported by the tags ':consts' and ':all'.
 
+BENCHMARKS
+    The following timings were obtained by running the "samples/bench.pl"
+    script with perl 5.8.8 on a Core 2 Duo 2.66GHz machine. The "_pp"
+    entries are the pure Perl versions, while "_bv" are Bit::Vector
+    versions.
+
+    Filling bits at a given position :
+                          Rate vfill_pp vfill_bv    vfill
+            vfill_pp    80.3/s       --    -100%    -100%
+            vfill_bv 1053399/s 1312401%       --     -11%
+            vfill    1180792/s 1471129%      12%       --
+
+    Copying bits from a bit vector to a different one :
+                         Rate vcopy_pp vcopy_bv    vcopy
+            vcopy_pp    112/s       --    -100%    -100%
+            vcopy_bv  62599/s   55622%       --     -89%
+            vcopy    558491/s  497036%     792%       --
+
+    Moving bits in the same bit vector from a given position to a different
+    one :
+                         Rate vmove_pp vmove_bv    vmove
+            vmove_pp   64.8/s       --    -100%    -100%
+            vmove_bv  64742/s   99751%       --     -88%
+            vmove    547980/s  845043%     746%       --
+
+    Testing bit equality from different positions of different bit vectors :
+                       Rate  veq_pp  veq_bv     veq
+            veq_pp   92.7/s      --   -100%   -100%
+            veq_bv  32777/s  35241%      --    -94%
+            veq    505828/s 545300%   1443%      --
+
 CAVEATS
     Please report architectures where we can't use the alignment as the move
     unit. I'll add exceptions for them.
 CAVEATS
     Please report architectures where we can't use the alignment as the move
     unit. I'll add exceptions for them.
index 3da4ad8cff1350a04b219de0c726ffbc0e7561c9..5d88b5ce07b5ace64ee37e116752f6b45e822bfc 100644 (file)
@@ -11,13 +11,13 @@ Scalar::Vec::Util - Utility routines for vec strings.
 
 =head1 VERSION
 
 
 =head1 VERSION
 
-Version 0.02
+Version 0.03
 
 =cut
 
 our $VERSION;
 BEGIN {
 
 =cut
 
 our $VERSION;
 BEGIN {
- $VERSION = '0.02';
+ $VERSION = '0.03';
  eval {
   require XSLoader;
   XSLoader::load(__PACKAGE__, $VERSION);
  eval {
   require XSLoader;
   XSLoader::load(__PACKAGE__, $VERSION);
@@ -133,6 +133,42 @@ our %EXPORT_TAGS    = (
 our @EXPORT_OK      = map { @$_ } values %EXPORT_TAGS;
 $EXPORT_TAGS{'all'} = [ @EXPORT_OK ];
 
 our @EXPORT_OK      = map { @$_ } values %EXPORT_TAGS;
 $EXPORT_TAGS{'all'} = [ @EXPORT_OK ];
 
+=head1 BENCHMARKS
+
+The following timings were obtained by running the C<samples/bench.pl> script with perl 5.8.8 on a Core 2 Duo 2.66GHz machine. The C<_pp> entries are the pure Perl versions, while C<_bv> are L<Bit::Vector> versions.
+
+=over 4
+
+=item Filling bits at a given position :
+
+                  Rate vfill_pp vfill_bv    vfill
+    vfill_pp    80.3/s       --    -100%    -100%
+    vfill_bv 1053399/s 1312401%       --     -11%
+    vfill    1180792/s 1471129%      12%       --
+
+=item Copying bits from a bit vector to a different one :
+
+                 Rate vcopy_pp vcopy_bv    vcopy
+    vcopy_pp    112/s       --    -100%    -100%
+    vcopy_bv  62599/s   55622%       --     -89%
+    vcopy    558491/s  497036%     792%       --
+
+=item Moving bits in the same bit vector from a given position to a different one :
+
+                 Rate vmove_pp vmove_bv    vmove
+    vmove_pp   64.8/s       --    -100%    -100%
+    vmove_bv  64742/s   99751%       --     -88%
+    vmove    547980/s  845043%     746%       --
+
+=item Testing bit equality from different positions of different bit vectors :
+
+               Rate  veq_pp  veq_bv     veq
+    veq_pp   92.7/s      --   -100%   -100%
+    veq_bv  32777/s  35241%      --    -94%
+    veq    505828/s 545300%   1443%      --
+
+=back
+
 =head1 CAVEATS
 
 Please report architectures where we can't use the alignment as the move unit. I'll add exceptions for them.
 =head1 CAVEATS
 
 Please report architectures where we can't use the alignment as the move unit. I'll add exceptions for them.
index 3b736980239696e41143a76bc0117ca6d6dd31bb..9260606ea16cdb9df85d1135ef1430e8590604a3 100755 (executable)
@@ -7,6 +7,8 @@ use Benchmark qw/cmpthese/;
 
 use lib qw{blib/arch blib/lib};
 use Scalar::Vec::Util qw/vfill vcopy veq/;
 
 use lib qw{blib/arch blib/lib};
 use Scalar::Vec::Util qw/vfill vcopy veq/;
+my $has_bv = eval "use Bit::Vector; 1" || 0;
+print 'We ' . ('don\'t ' x !$has_bv) . "have Bit::Vector.\n";
 
 my $n = 100_000;
 my $i = 0;
 
 my $n = 100_000;
 my $i = 0;
@@ -18,10 +20,20 @@ sub inc {
  return $_[0];
 }
 
  return $_[0];
 }
 
+sub len {
+ return $n - ($_[0] > $_[1] ? $_[0] : $_[1])
+}
+
+my ($bv1, $bv2, $bv3, $bv4);
+if ($has_bv) {
+ ($bv1, $bv2, $bv3, $bv4) = Bit::Vector->new($n, 4);
+}
+
 print "fill:\n";
 cmpthese -3, {
 print "fill:\n";
 cmpthese -3, {
- vfill    => sub { vfill $x, inc($i), $n - $i, 1; },
- vfill_pp => sub { Scalar::Vec::Util::vfill_pp($x, inc($i), $n - $i, 1); }
+ vfill     => sub { vfill $x, inc($i), $n - $i, 1 },
+ vfill_pp  => sub { Scalar::Vec::Util::vfill_pp($x, inc($i), $n - $i, 1) },
+ (vfill_bv => sub { $bv1->Interval_Fill(inc($i), $n - 1) }) x $has_bv
 };
 
 $i = 0;
 };
 
 $i = 0;
@@ -29,24 +41,40 @@ my $j = int $n / 2;
 my $y = '';
 print "\ncopy:\n";
 cmpthese -3, {
 my $y = '';
 print "\ncopy:\n";
 cmpthese -3, {
- vcopy    => sub { vcopy $x, inc($i), $y, inc($j), $n - ($i > $j ? $i : $j); },
- vcopy_pp => sub { Scalar::Vec::Util::vcopy_pp($x, inc($i), $y, inc($j), $n - ($i > $j ? $i : $j)); }
+ vcopy     => sub { vcopy $x, inc($i), $y, inc($j), len($i, $j) },
+ vcopy_pp  => sub { Scalar::Vec::Util::vcopy_pp($x, inc($i), $y, inc($j), len($i, $j)) },
+ (vcopy_bv => sub { $bv2->Interval_Copy($bv1, inc($j), inc($i), len($i, $j)) }) x $has_bv
 };
 
 $i = 0;
 $j = int $n / 2;
 print "\nmove:\n";
 cmpthese -3, {
 };
 
 $i = 0;
 $j = int $n / 2;
 print "\nmove:\n";
 cmpthese -3, {
- vcopy    => sub { vcopy $x, inc($i), $x, inc($j), $n - ($i > $j ? $i : $j); },
- vcopy_pp => sub { Scalar::Vec::Util::vcopy_pp($x, inc($i), $x, inc($j), $n - ($i > $j ? $i : $j)); }
+ vmove     => sub { vcopy $x, inc($i), $x, inc($j), len($i, $j) },
+ vmove_pp  => sub { Scalar::Vec::Util::vcopy_pp($x, inc($i), $x, inc($j), len($i, $j)) },
+ (vmove_bv => sub { $bv1->Interval_Copy($bv1, inc($j), inc($i), len($i, $j)) }) x $has_bv
 };
 
 $i = 0;
 $j = int $n / 2;
 vfill $x, 0, $n, 1;
 vfill $y, 0, $n, 1;
 };
 
 $i = 0;
 $j = int $n / 2;
 vfill $x, 0, $n, 1;
 vfill $y, 0, $n, 1;
+if ($has_bv) {
+ $bv1->Fill();
+ $bv2->Fill();
+}
 print "\neq:\n";
 cmpthese -3, {
 print "\neq:\n";
 cmpthese -3, {
- veq    => sub { veq $x, inc($i), $y, inc($j), $n - ($i > $j ? $i : $j); },
- veq_pp => sub { Scalar::Vec::Util::veq_pp($x, inc($i), $y, inc($j), $n - ($i > $j ? $i : $j)); }
+ veq     => sub { veq $x, inc($i), $y, inc($j), len($i, $j) },
+ veq_pp  => sub { Scalar::Vec::Util::veq_pp($x, inc($i), $y, inc($j), len($i, $j)) },
+ (veq_bv => sub {
+   inc($i);
+   inc($j);
+   my $l = len($i, $j);
+   $bv3->Resize($l);
+   $bv3->Interval_Copy($bv1, 0, $i, $l);
+   $bv4->Resize($l);
+   $bv4->Interval_Copy($bv2, 0, $j, $l);
+   $bv3->equal($bv4);
+  }) x $has_bv
 };
 };