| 1 | package Benchmark::Perl::Formance::Plugin::PerlStone2015::07lists; | ||||||||||
| 2 | 1 | our $AUTHORITY = 'cpan:SCHWIGON'; | |||||||||
| 3 | # ABSTRACT: benchmark - perl 07 - lists | ||||||||||
| 4 | 1 | $Benchmark::Perl::Formance::Plugin::PerlStone2015::07lists::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 | ▶ | use Benchmark ':hireswallclock'; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 15 | 1 | ▶ | use Data::Dumper; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 16 | |||||||||||
| 17 | sub _unshift | ||||||||||
| 18 | 0 | ▶ | { | ||||||||
|
Subroutine
_unshift: not called CC=3 SCAR=24.8
| |||||||||||
| 19 | 0 | my ($options) = @_; | |||||||||
| 20 | |||||||||||
| 21 | 0 | ▶ | my $goal = $options->{fastmode} ? 1_000_000 : 1_000_000; | ||||||||
|
Branch: 1 branch
| |||||||||||
| 22 | 0 | ▶ | my $count = $options->{fastmode} ? 5 : 100; | ||||||||
|
Branch: 1 branch
| |||||||||||
| 23 | 0 | my $s = "somestring" x 50; | |||||||||
| 24 | |||||||||||
| 25 | 0 | ▶ | my $t = timeit $count, sub { | ||||||||
|
Subroutine
__ANON__: not called CC=2 SCAR=17.9
| |||||||||||
| 26 | 0 | my @stuff = (); | |||||||||
| 27 | 0 | unshift @stuff, $s for 1..$goal; | |||||||||
| 28 | 0 | }; | |||||||||
| 29 | |||||||||||
| 30 | return { | ||||||||||
| 31 | 0 | Benchmark => $t, | |||||||||
| 32 | goal => $goal, | ||||||||||
| 33 | count => $count, | ||||||||||
| 34 | }; | ||||||||||
| 35 | } | ||||||||||
| 36 | |||||||||||
| 37 | sub _push | ||||||||||
| 38 | 0 | ▶ | { | ||||||||
|
Subroutine
_push: not called CC=3 SCAR=24.8
| |||||||||||
| 39 | 0 | my ($options) = @_; | |||||||||
| 40 | |||||||||||
| 41 | 0 | ▶ | my $goal = $options->{fastmode} ? 1_000_000 : 1_000_000; | ||||||||
|
Branch: 1 branch
| |||||||||||
| 42 | 0 | ▶ | my $count = $options->{fastmode} ? 5 : 100; | ||||||||
|
Branch: 1 branch
| |||||||||||
| 43 | 0 | my $s = "somestring" x 50; | |||||||||
| 44 | |||||||||||
| 45 | 0 | ▶ | my $t = timeit $count, sub { | ||||||||
|
Subroutine
__ANON__: not called CC=2 SCAR=17.9
| |||||||||||
| 46 | 0 | my @stuff = (); | |||||||||
| 47 | 0 | push @stuff, $s for 1..$goal; | |||||||||
| 48 | 0 | }; | |||||||||
| 49 | |||||||||||
| 50 | return { | ||||||||||
| 51 | 0 | Benchmark => $t, | |||||||||
| 52 | goal => $goal, | ||||||||||
| 53 | count => $count, | ||||||||||
| 54 | }; | ||||||||||
| 55 | } | ||||||||||
| 56 | |||||||||||
| 57 | sub main | ||||||||||
| 58 | 0 | ▶ | { | ||||||||
|
Subroutine
main: not called CC=3 SCAR=24.8
Pod
undocumented
| |||||||||||
| 59 | 0 | my ($options) = @_; | |||||||||
| 60 | |||||||||||
| 61 | 0 | my $results; | |||||||||
| 62 | 0 | eval { | |||||||||
| 63 | 0 | $results = { | |||||||||
| 64 | unshift => _unshift($options), | ||||||||||
| 65 | push => _push($options), | ||||||||||
| 66 | }; | ||||||||||
| 67 | }; | ||||||||||
| 68 | |||||||||||
| 69 | 0 | ▶ | if ($@) { | ||||||||
|
Branch: 1 branch
| |||||||||||
| 70 | 0 | ▶ | warn $@ if $options->{verbose}; | ||||||||
|
Branch: 1 branch
| |||||||||||
| 71 | 0 | $results = { failed => $@ }; | |||||||||
| 72 | } | ||||||||||
| 73 | |||||||||||
| 74 | 0 | return $results; | |||||||||
| 75 | } | ||||||||||
| 76 | |||||||||||
| 77 | 1 | 1; | |||||||||
| 78 | |||||||||||
| 79 | __END__ | ||||||||||