| 1 | package Benchmark::Perl::Formance::Plugin::PerlStone2015::mem; | ||||||||||
| 2 | 1 | our $AUTHORITY = 'cpan:SCHWIGON'; | |||||||||
| 3 | # ABSTRACT: benchmark - mem - memory operations | ||||||||||
| 4 | 1 | $Benchmark::Perl::Formance::Plugin::PerlStone2015::mem::VERSION = '0.002'; | |||||||||
| 5 | 1 | ▶ | use strict; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 6 | 1 | ▶ | use warnings; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 7 | |||||||||||
| 8 | ############################################################# | ||||||||||
| 9 | # # | ||||||||||
| 10 | # Benchmark Code ahead - Don't touch without strong reason! # | ||||||||||
| 11 | # # | ||||||||||
| 12 | ############################################################# | ||||||||||
| 13 | |||||||||||
| 14 | 1 | our $goal; | |||||||||
| 15 | 1 | our $count; | |||||||||
| 16 | |||||||||||
| 17 | 1 | ▶ | use Benchmark ':hireswallclock'; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 18 | |||||||||||
| 19 | 1 | my @stuff; | |||||||||
| 20 | |||||||||||
| 21 | sub allocate | ||||||||||
| 22 | 0 | ▶ | { | ||||||||
|
Subroutine
allocate: not called CC=2 SCAR=17.9
Pod
undocumented
| |||||||||||
| 23 | 0 | my ($options, $goal, $count) = @_; | |||||||||
| 24 | |||||||||||
| 25 | 0 | ▶ | my $mygoal = ($options->{fastmode} ? 10 : 1) * $goal; | ||||||||
|
Branch: 1 branch
| |||||||||||
| 26 | 0 | ▶ | my $t = timeit $count, sub { | ||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=6.9
| |||||||||||
| 27 | 0 | my @stuff1; | |||||||||
| 28 | 0 | $#stuff1 = $mygoal; | |||||||||
| 29 | 0 | }; | |||||||||
| 30 | return { | ||||||||||
| 31 | 0 | Benchmark => $t, | |||||||||
| 32 | goal => $mygoal, | ||||||||||
| 33 | count => $count, | ||||||||||
| 34 | }; | ||||||||||
| 35 | } | ||||||||||
| 36 | |||||||||||
| 37 | sub copy | ||||||||||
| 38 | 0 | ▶ | { | ||||||||
|
Subroutine
copy: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||
| 39 | 0 | my ($options, $goal, $count) = @_; | |||||||||
| 40 | |||||||||||
| 41 | 0 | ▶ | my $t = timeit $count, sub { | ||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=6.9
| |||||||||||
| 42 | 0 | my @copy = @stuff; | |||||||||
| 43 | 0 | }; | |||||||||
| 44 | return { | ||||||||||
| 45 | 0 | Benchmark => $t, | |||||||||
| 46 | goal => $goal, | ||||||||||
| 47 | count => $count, | ||||||||||
| 48 | }; | ||||||||||
| 49 | } | ||||||||||
| 50 | |||||||||||
| 51 | sub main | ||||||||||
| 52 | 0 | ▶ | { | ||||||||
|
Subroutine
main: not called CC=4 SCAR=30.0
Pod
undocumented
| |||||||||||
| 53 | 0 | my ($options) = @_; | |||||||||
| 54 | |||||||||||
| 55 | 0 | ▶ | $goal = $options->{fastmode} ? 2_000_000 : 15_000_000; | ||||||||
|
Branch: 1 branch
| |||||||||||
| 56 | 0 | ▶ | $count = $options->{fastmode} ? 5 : 20; | ||||||||
|
Branch: 1 branch
| |||||||||||
| 57 | |||||||||||
| 58 | 0 | $#stuff = $goal; | |||||||||
| 59 | 0 | my $size; | |||||||||
| 60 | 0 | eval qq{use Devel::Size 'total_size'}; | |||||||||
| 61 | 0 | ▶ | if ($@) { | ||||||||
|
Branch: 1 branch
| |||||||||||
| 62 | 0 | $size = "error-no-Devel-Size-available"; | |||||||||
| 63 | } else { | ||||||||||
| 64 | 0 | $size = total_size(\@stuff); | |||||||||
| 65 | } | ||||||||||
| 66 | |||||||||||
| 67 | return { | ||||||||||
| 68 | 0 | total_size_bytes => $size, | |||||||||
| 69 | copy => copy ($options, $goal, $count), | ||||||||||
| 70 | allocate => allocate ($options, $goal, $count), | ||||||||||
| 71 | }; | ||||||||||
| 72 | } | ||||||||||
| 73 | |||||||||||
| 74 | 1 | 1; | |||||||||
| 75 | |||||||||||
| 76 | __END__ | ||||||||||