Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

conditionally use Devel::Size if available

Devel::Size does not work on all
old Perl versions. Although it would
be extremely interesting what values it
reports for the benchmarked data but
it is not worth to fail on that.
  • Loading branch information...
commit 3216685458deaabb7c8fb5ddf724f4e6ea71d5f9 1 parent 89a20ac
@renormalist authored
View
11 lib/Benchmark/Perl/Formance/Plugin/DPath.pm
@@ -3,7 +3,7 @@ package Benchmark::Perl::Formance::Plugin::DPath;
use strict;
use warnings;
-our $VERSION = "0.001";
+our $VERSION = "0.002";
#############################################################
# #
@@ -15,7 +15,6 @@ our $goal;
our $count;
use Clone 'clone';
-use Devel::Size 'total_size';
use Benchmark ':all', ':hireswallclock';
# example use-case is a medium sized TAP-DOM, which we blow up
@@ -447,7 +446,13 @@ sub run_dpath
my @huge_expected = map { $expected } 1..$multi;
$huge_data->{$_} = clone ( $base_data ) foreach 1..$multi;
- my $data_size = total_size ($huge_data);
+ my $data_size;
+ eval qq{use Devel::Size 'total_size'};
+ if ($@) {
+ $data_size = "error-no-Devel-Size-available";
+ } else {
+ $data_size = total_size ($huge_data);
+ }
print STDERR "# Running benchmark. Can take some time ..." if $options->{verbose} && $options->{verbose} > 2;
my $t;
View
11 lib/Benchmark/Perl/Formance/Plugin/Incubator.pm
@@ -3,7 +3,7 @@ package Benchmark::Perl::Formance::Plugin::Incubator;
use strict;
use warnings;
-our $VERSION = "0.001";
+our $VERSION = "0.002";
#############################################################
# #
@@ -12,7 +12,6 @@ our $VERSION = "0.001";
#############################################################
use Benchmark ':hireswallclock';
-use Devel::Size 'total_size';
use Math::MatrixReal;
sub matrix_multiply_fixsize
@@ -27,7 +26,13 @@ sub matrix_multiply_fixsize
my @row; $row[$_] = 1 foreach 0..$minigoal-1;
my @matrix; $matrix[$_] = [ @row ] foreach 0..$minigoal-1;
- my $size = total_size(\@matrix);
+ my $size;
+ eval qq{use Devel::Size 'total_size'};
+ if ($@) {
+ $size = "error-no-Devel-Size-available";
+ } else {
+ $size = total_size(\@matrix);
+ }
my $m = Math::MatrixReal->new_from_rows(\@matrix);
my $result;
View
11 lib/Benchmark/Perl/Formance/Plugin/Mem.pm
@@ -3,7 +3,7 @@ package Benchmark::Perl::Formance::Plugin::Mem;
use strict;
use warnings;
-our $VERSION = "0.002";
+our $VERSION = "0.003";
#############################################################
# #
@@ -15,7 +15,6 @@ our $goal;
our $count;
use Benchmark ':hireswallclock';
-use Devel::Size 'total_size';
my @stuff;
@@ -57,7 +56,13 @@ sub main
$count = $options->{fastmode} ? 5 : 20;
$#stuff = $goal;
- my $size = total_size(\@stuff);
+ my $size;
+ eval qq{use Devel::Size 'total_size'};
+ if ($@) {
+ $size = "error-no-Devel-Size-available";
+ } else {
+ $size = total_size(\@stuff);
+ }
return {
total_size_bytes => $size,
View
11 lib/Benchmark/Perl/Formance/Plugin/ThreadsShared.pm
@@ -6,7 +6,7 @@ use 5.008;
use strict;
use warnings;
-our $VERSION = "0.001";
+our $VERSION = "0.002";
#############################################################
# #
@@ -24,13 +24,18 @@ use threads;
use threads::shared;
use Benchmark ':hireswallclock';
-use Devel::Size 'total_size';
use Data::Dumper;
my @result : shared;
$#result = 1_000;
-my $size = total_size(\@result);
+my $size;
+eval qq{use Devel::Size 'total_size'};
+if ($@) {
+ $size = "error-no-Devel-Size-available";
+} else {
+ $size = total_size(\@result);
+}
sub run_thread_storm_shared
{

0 comments on commit 3216685

Please sign in to comment.
Something went wrong with that request. Please try again.