Filename | /home/s1/perl5/perlbrew/perls/perl-5.22.1/lib/site_perl/5.22.1/experimental.pm |
Statements | Executed 98 statements in 3.56ms |
Calls | P | F | Exclusive Time |
Inclusive Time |
Subroutine |
---|---|---|---|---|---|
1 | 1 | 1 | 5.82ms | 6.22ms | BEGIN@8 | experimental::
1 | 1 | 1 | 2.38ms | 5.35ms | BEGIN@5 | experimental::
1 | 1 | 1 | 1.41ms | 1.41ms | BEGIN@7 | experimental::
1 | 1 | 1 | 41µs | 46µs | BEGIN@3 | experimental::
70 | 1 | 1 | 18µs | 18µs | CORE:match (opcode) | experimental::
1 | 1 | 1 | 12µs | 29µs | BEGIN@4 | experimental::
1 | 1 | 1 | 11µs | 26µs | _enable | experimental::
1 | 1 | 1 | 10µs | 36µs | import | experimental::
0 | 0 | 0 | 0s | 0s | _disable | experimental::
0 | 0 | 0 | 0s | 0s | unimport | experimental::
Line | State ments |
Time on line |
Calls | Time in subs |
Code |
---|---|---|---|---|---|
1 | package experimental; | ||||
2 | 1 | 800ns | $experimental::VERSION = '0.016'; | ||
3 | 2 | 52µs | 2 | 50µs | # spent 46µs (41+5) within experimental::BEGIN@3 which was called:
# once (41µs+5µs) by DateTime::Format::Alami::BEGIN@384 at line 3 # spent 46µs making 1 call to experimental::BEGIN@3
# spent 4µs making 1 call to strict::import |
4 | 2 | 41µs | 2 | 46µs | # spent 29µs (12+17) within experimental::BEGIN@4 which was called:
# once (12µs+17µs) by DateTime::Format::Alami::BEGIN@384 at line 4 # spent 29µs making 1 call to experimental::BEGIN@4
# spent 17µs making 1 call to warnings::import |
5 | 2 | 464µs | 1 | 5.35ms | # spent 5.35ms (2.38+2.96) within experimental::BEGIN@5 which was called:
# once (2.38ms+2.96ms) by DateTime::Format::Alami::BEGIN@384 at line 5 # spent 5.35ms making 1 call to experimental::BEGIN@5 |
6 | |||||
7 | 2 | 1.41ms | 1 | 1.41ms | # spent 1.41ms within experimental::BEGIN@7 which was called:
# once (1.41ms+0s) by DateTime::Format::Alami::BEGIN@384 at line 7 # spent 1.41ms making 1 call to experimental::BEGIN@7 |
8 | 2 | 1.19ms | 2 | 6.30ms | # spent 6.22ms (5.82+402µs) within experimental::BEGIN@8 which was called:
# once (5.82ms+402µs) by DateTime::Format::Alami::BEGIN@384 at line 8 # spent 6.22ms making 1 call to experimental::BEGIN@8
# spent 74µs making 1 call to Exporter::import |
9 | |||||
10 | 71 | 206µs | 70 | 18µs | my %warnings = map { $_ => 1 } grep { /^experimental::/ } keys %warnings::Offsets; # spent 18µs making 70 calls to experimental::CORE:match, avg 259ns/call |
11 | 1 | 12µ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 | 9µ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 | 900ns | my %max_version = ( | ||
42 | lexical_topic => '5.23.4', | ||||
43 | ); | ||||
44 | |||||
45 | 1 | 121µs | 19 | 65µs | $_ = version->new($_) for values %min_version; # spent 65µs making 19 calls to version::vxs::new, avg 3µs/call |
46 | 1 | 8µs | 1 | 3µs | $_ = version->new($_) for values %max_version; # spent 3µs making 1 call to version::vxs::new |
47 | |||||
48 | 1 | 3µs | my %additional = ( | ||
49 | postderef => ['postderef_qq'], | ||||
50 | switch => ['smartmatch'], | ||||
51 | ); | ||||
52 | |||||
53 | # spent 26µs (11+16) within experimental::_enable which was called:
# once (11µs+16µs) by experimental::import at line 85 | ||||
54 | 1 | 600ns | my $pragma = shift; | ||
55 | 1 | 6µs | if ($warnings{"experimental::$pragma"}) { | ||
56 | 1 | 2µs | 1 | 16µs | warnings->unimport("experimental::$pragma"); # spent 16µs making 1 call to warnings::unimport |
57 | 1 | 500ns | 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 36µs (10+26) within experimental::import which was called:
# once (10µs+26µs) by DateTime::Format::Alami::BEGIN@384 at line 384 of DateTime/Format/Alami.pm | ||||
82 | 1 | 1µs | my ($self, @pragmas) = @_; | ||
83 | |||||
84 | 1 | 1µs | for my $pragma (@pragmas) { | ||
85 | 1 | 2µs | 1 | 26µs | _enable($pragma); # spent 26µ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 | 21µs | 1; | ||
116 | |||||
117 | #ABSTRACT: Experimental features made easy | ||||
118 | |||||
119 | __END__ | ||||
# spent 18µs within experimental::CORE:match which was called 70 times, avg 259ns/call:
# 70 times (18µs+0s) by DateTime::Format::Alami::BEGIN@384 at line 10, avg 259ns/call |