| Filename | /home/s1/perl5/perlbrew/perls/perl-5.22.1/lib/site_perl/5.22.1/experimental.pm |
| Statements | Executed 98 statements in 2.95ms |
| Calls | P | F | Exclusive Time |
Inclusive Time |
Subroutine |
|---|---|---|---|---|---|
| 1 | 1 | 1 | 4.18ms | 4.51ms | experimental::BEGIN@8 |
| 1 | 1 | 1 | 1.68ms | 3.80ms | experimental::BEGIN@5 |
| 1 | 1 | 1 | 1.19ms | 1.19ms | experimental::BEGIN@7 |
| 1 | 1 | 1 | 54µs | 82µs | experimental::import |
| 1 | 1 | 1 | 19µs | 22µs | experimental::BEGIN@3 |
| 70 | 1 | 1 | 14µs | 14µs | experimental::CORE:match (opcode) |
| 1 | 1 | 1 | 12µs | 28µs | experimental::_enable |
| 1 | 1 | 1 | 10µs | 15µs | experimental::BEGIN@4 |
| 0 | 0 | 0 | 0s | 0s | experimental::_disable |
| 0 | 0 | 0 | 0s | 0s | experimental::unimport |
| Line | State ments |
Time on line |
Calls | Time in subs |
Code |
|---|---|---|---|---|---|
| 1 | package experimental; | ||||
| 2 | 1 | 500ns | $experimental::VERSION = '0.016'; | ||
| 3 | 2 | 35µs | 2 | 25µs | # spent 22µs (19+3) within experimental::BEGIN@3 which was called:
# once (19µs+3µs) by DateTime::Format::Alami::BEGIN@394 at line 3 # spent 22µs making 1 call to experimental::BEGIN@3
# spent 3µs making 1 call to strict::import |
| 4 | 2 | 25µs | 2 | 20µs | # spent 15µs (10+5) within experimental::BEGIN@4 which was called:
# once (10µs+5µs) by DateTime::Format::Alami::BEGIN@394 at line 4 # spent 15µs making 1 call to experimental::BEGIN@4
# spent 5µs making 1 call to warnings::import |
| 5 | 2 | 298µs | 1 | 3.80ms | # spent 3.80ms (1.68+2.12) within experimental::BEGIN@5 which was called:
# once (1.68ms+2.12ms) by DateTime::Format::Alami::BEGIN@394 at line 5 # spent 3.80ms making 1 call to experimental::BEGIN@5 |
| 6 | |||||
| 7 | 2 | 1.19ms | 1 | 1.19ms | # spent 1.19ms within experimental::BEGIN@7 which was called:
# once (1.19ms+0s) by DateTime::Format::Alami::BEGIN@394 at line 7 # spent 1.19ms making 1 call to experimental::BEGIN@7 |
| 8 | 2 | 1.06ms | 2 | 4.58ms | # spent 4.51ms (4.18+331µs) within experimental::BEGIN@8 which was called:
# once (4.18ms+331µs) by DateTime::Format::Alami::BEGIN@394 at line 8 # spent 4.51ms making 1 call to experimental::BEGIN@8
# spent 72µs making 1 call to Exporter::import |
| 9 | |||||
| 10 | 71 | 180µs | 70 | 14µs | my %warnings = map { $_ => 1 } grep { /^experimental::/ } keys %warnings::Offsets; # spent 14µs making 70 calls to experimental::CORE:match, avg 194ns/call |
| 11 | 1 | 9µs | my %features = map { $_ => 1 } $] > 5.015006 ? keys %feature::feature : do { | ||
| 12 | my @features; | ||||
| 13 | if ($] >= 5.010) { | ||||
| 14 | push @features, qw/switch say state/; | ||||
| 15 | push @features, 'unicode_strings' if $] > 5.011002; | ||||
| 16 | } | ||||
| 17 | @features; | ||||
| 18 | }; | ||||
| 19 | |||||
| 20 | 1 | 15µs | my %min_version = ( | ||
| 21 | array_base => '5', | ||||
| 22 | autoderef => '5.14.0', | ||||
| 23 | bitwise => '5.22.0', | ||||
| 24 | current_sub => '5.16.0', | ||||
| 25 | evalbytes => '5.16.0', | ||||
| 26 | fc => '5.16.0', | ||||
| 27 | lexical_topic => '5.10.0', | ||||
| 28 | lexical_subs => '5.18.0', | ||||
| 29 | postderef => '5.20.0', | ||||
| 30 | postderef_qq => '5.20.0', | ||||
| 31 | refaliasing => '5.22.0', | ||||
| 32 | regex_sets => '5.18.0', | ||||
| 33 | say => '5.10.0', | ||||
| 34 | smartmatch => '5.10.0', | ||||
| 35 | signatures => '5.20.0', | ||||
| 36 | state => '5.10.0', | ||||
| 37 | switch => '5.10.0', | ||||
| 38 | unicode_eval => '5.16.0', | ||||
| 39 | unicode_strings => '5.12.0', | ||||
| 40 | ); | ||||
| 41 | 1 | 600ns | my %max_version = ( | ||
| 42 | lexical_topic => '5.23.4', | ||||
| 43 | ); | ||||
| 44 | |||||
| 45 | 1 | 95µs | 19 | 53µs | $_ = version->new($_) for values %min_version; # spent 53µs making 19 calls to version::vxs::new, avg 3µs/call |
| 46 | 1 | 6µs | 1 | 2µs | $_ = version->new($_) for values %max_version; # spent 2µs making 1 call to version::vxs::new |
| 47 | |||||
| 48 | 1 | 2µs | my %additional = ( | ||
| 49 | postderef => ['postderef_qq'], | ||||
| 50 | switch => ['smartmatch'], | ||||
| 51 | ); | ||||
| 52 | |||||
| 53 | # spent 28µs (12+16) within experimental::_enable which was called:
# once (12µs+16µs) by experimental::import at line 85 | ||||
| 54 | 1 | 500ns | my $pragma = shift; | ||
| 55 | 1 | 5µs | if ($warnings{"experimental::$pragma"}) { | ||
| 56 | 1 | 3µs | 1 | 16µs | warnings->unimport("experimental::$pragma"); # spent 16µs making 1 call to warnings::unimport |
| 57 | 1 | 700ns | feature->import($pragma) if exists $features{$pragma}; | ||
| 58 | 1 | 500ns | _enable(@{ $additional{$pragma} }) if $additional{$pragma}; | ||
| 59 | } | ||||
| 60 | elsif ($features{$pragma}) { | ||||
| 61 | feature->import($pragma); | ||||
| 62 | _enable(@{ $additional{$pragma} }) if $additional{$pragma}; | ||||
| 63 | } | ||||
| 64 | elsif (not exists $min_version{$pragma}) { | ||||
| 65 | croak "Can't enable unknown feature $pragma"; | ||||
| 66 | } | ||||
| 67 | elsif ($] < $min_version{$pragma}) { | ||||
| 68 | my $stable = $min_version{$pragma}; | ||||
| 69 | if ($stable->{version}[1] % 2) { | ||||
| 70 | $stable = version->new( | ||||
| 71 | "5.".($stable->{version}[1]+1).'.0' | ||||
| 72 | ); | ||||
| 73 | } | ||||
| 74 | croak "Need perl $stable or later for feature $pragma"; | ||||
| 75 | } | ||||
| 76 | elsif ($] >= ($max_version{$pragma} || 7)) { | ||||
| 77 | croak "Experimental feature $pragma has been removed from perl in version $max_version{$pragma}"; | ||||
| 78 | } | ||||
| 79 | } | ||||
| 80 | |||||
| 81 | # spent 82µs (54+28) within experimental::import which was called:
# once (54µs+28µs) by DateTime::Format::Alami::BEGIN@394 at line 394 of lib/DateTime/Format/Alami.pm | ||||
| 82 | 1 | 2µs | my ($self, @pragmas) = @_; | ||
| 83 | |||||
| 84 | 1 | 1µs | for my $pragma (@pragmas) { | ||
| 85 | 1 | 2µs | 1 | 28µs | _enable($pragma); # spent 28µs making 1 call to experimental::_enable |
| 86 | } | ||||
| 87 | 1 | 4µs | return; | ||
| 88 | } | ||||
| 89 | |||||
| 90 | sub _disable { | ||||
| 91 | my $pragma = shift; | ||||
| 92 | if ($warnings{"experimental::$pragma"}) { | ||||
| 93 | warnings->import("experimental::$pragma"); | ||||
| 94 | feature->unimport($pragma) if exists $features{$pragma}; | ||||
| 95 | _disable(@{ $additional{$pragma} }) if $additional{$pragma}; | ||||
| 96 | } | ||||
| 97 | elsif ($features{$pragma}) { | ||||
| 98 | feature->unimport($pragma); | ||||
| 99 | _disable(@{ $additional{$pragma} }) if $additional{$pragma}; | ||||
| 100 | } | ||||
| 101 | elsif (not exists $min_version{$pragma}) { | ||||
| 102 | carp "Can't disable unknown feature $pragma, ignoring"; | ||||
| 103 | } | ||||
| 104 | } | ||||
| 105 | |||||
| 106 | sub unimport { | ||||
| 107 | my ($self, @pragmas) = @_; | ||||
| 108 | |||||
| 109 | for my $pragma (@pragmas) { | ||||
| 110 | _disable($pragma); | ||||
| 111 | } | ||||
| 112 | return; | ||||
| 113 | } | ||||
| 114 | |||||
| 115 | 1 | 16µs | 1; | ||
| 116 | |||||
| 117 | #ABSTRACT: Experimental features made easy | ||||
| 118 | |||||
| 119 | __END__ | ||||
# spent 14µs within experimental::CORE:match which was called 70 times, avg 194ns/call:
# 70 times (14µs+0s) by DateTime::Format::Alami::BEGIN@394 at line 10, avg 194ns/call |