Filename | /home/ss5/perl5/perlbrew/perls/perl-5.22.0/lib/site_perl/5.22.0/Exporter/Lite.pm |
Statements | Executed 26 statements in 340µs |
Calls | P | F | Exclusive Time |
Inclusive Time |
Subroutine |
---|---|---|---|---|---|
2 | 1 | 1 | 16µs | 18µs | _export | Exporter::Lite::
2 | 2 | 2 | 11µs | 29µs | import | Exporter::Lite::
1 | 1 | 1 | 8µs | 10µs | BEGIN@4 | Exporter::Lite::
1 | 1 | 1 | 5µs | 12µs | BEGIN@50 | Exporter::Lite::
1 | 1 | 1 | 4µs | 5µs | BEGIN@5 | Exporter::Lite::
1 | 1 | 1 | 4µs | 10µs | BEGIN@15 | Exporter::Lite::
2 | 1 | 1 | 2µs | 2µs | CORE:subst (opcode) | Exporter::Lite::
0 | 0 | 0 | 0s | 0s | _not_exported | Exporter::Lite::
Line | State ments |
Time on line |
Calls | Time in subs |
Code |
---|---|---|---|---|---|
1 | package Exporter::Lite; | ||||
2 | |||||
3 | 1 | 5µs | require 5.006; | ||
4 | 2 | 13µs | 2 | 13µs | # spent 10µs (8+3) within Exporter::Lite::BEGIN@4 which was called:
# once (8µs+3µs) by Time::Duration::Parse::BEGIN@8 at line 4 # spent 10µs making 1 call to Exporter::Lite::BEGIN@4
# spent 3µs making 1 call to warnings::import |
5 | 2 | 40µs | 2 | 6µs | # spent 5µs (4+900ns) within Exporter::Lite::BEGIN@5 which was called:
# once (4µs+900ns) by Time::Duration::Parse::BEGIN@8 at line 5 # spent 5µs making 1 call to Exporter::Lite::BEGIN@5
# spent 900ns making 1 call to strict::import |
6 | |||||
7 | 1 | 300ns | our $VERSION = '0.07'; | ||
8 | 1 | 500ns | our @EXPORT = qw(import); | ||
9 | |||||
10 | |||||
11 | # spent 29µs (11+18) within Exporter::Lite::import which was called 2 times, avg 14µs/call:
# once (6µs+10µs) by Time::Duration::Parse::BEGIN@8 at line 8 of Time/Duration/Parse.pm
# once (5µs+7µs) by CHI::Util::BEGIN@10 at line 10 of CHI/Util.pm | ||||
12 | 2 | 800ns | my($exporter, @imports) = @_; | ||
13 | 2 | 2µs | my($caller, $file, $line) = caller; | ||
14 | |||||
15 | 2 | 130µs | 2 | 16µs | # spent 10µs (4+6) within Exporter::Lite::BEGIN@15 which was called:
# once (4µs+6µs) by Time::Duration::Parse::BEGIN@8 at line 15 # spent 10µs making 1 call to Exporter::Lite::BEGIN@15
# spent 6µs making 1 call to strict::unimport |
16 | |||||
17 | 2 | 3µs | unless( @imports ) { # Default import. | ||
18 | @imports = @{$exporter.'::EXPORT'}; | ||||
19 | } | ||||
20 | else { | ||||
21 | # Because @EXPORT_OK = () would indicate that nothing is | ||||
22 | # to be exported, we cannot simply check the length of @EXPORT_OK. | ||||
23 | # We must to oddness to see if the variable exists at all as | ||||
24 | # well as avoid autovivification. | ||||
25 | # XXX idea stolen from base.pm, this might be all unnecessary | ||||
26 | my $eokglob; | ||||
27 | if( $eokglob = ${$exporter.'::'}{EXPORT_OK} and *$eokglob{ARRAY} ) { | ||||
28 | if( @{$exporter.'::EXPORT_OK'} ) { | ||||
29 | # This can also be cached. | ||||
30 | my %ok = map { s/^&//; $_ => 1 } @{$exporter.'::EXPORT_OK'}, | ||||
31 | @{$exporter.'::EXPORT'}; | ||||
32 | |||||
33 | my($denied) = grep {s/^&//; !$ok{$_}} @imports; | ||||
34 | _not_exported($denied, $exporter, $file, $line) if $denied; | ||||
35 | } | ||||
36 | else { # We don't export anything. | ||||
37 | _not_exported($imports[0], $exporter, $file, $line); | ||||
38 | } | ||||
39 | } | ||||
40 | } | ||||
41 | |||||
42 | 2 | 5µs | 2 | 18µs | _export($caller, $exporter, @imports); # spent 18µs making 2 calls to Exporter::Lite::_export, avg 9µs/call |
43 | } | ||||
44 | |||||
- - | |||||
47 | # spent 18µs (16+2) within Exporter::Lite::_export which was called 2 times, avg 9µs/call:
# 2 times (16µs+2µs) by Exporter::Lite::import at line 42, avg 9µs/call | ||||
48 | 2 | 700ns | my($caller, $exporter, @imports) = @_; | ||
49 | |||||
50 | 2 | 119µs | 2 | 19µs | # spent 12µs (5+7) within Exporter::Lite::BEGIN@50 which was called:
# once (5µs+7µs) by Time::Duration::Parse::BEGIN@8 at line 50 # spent 12µs making 1 call to Exporter::Lite::BEGIN@50
# spent 7µs making 1 call to strict::unimport |
51 | |||||
52 | # Stole this from Exporter::Heavy. I'm sure it can be written better | ||||
53 | # but I'm lazy at the moment. | ||||
54 | 2 | 5µs | foreach my $sym (@imports) { | ||
55 | # shortcut for the common case of no type character | ||||
56 | 2 | 14µs | 2 | 2µs | (*{$caller.'::'.$sym} = \&{$exporter.'::'.$sym}, next) # spent 2µs making 2 calls to Exporter::Lite::CORE:subst, avg 850ns/call |
57 | unless $sym =~ s/^(\W)//; | ||||
58 | |||||
59 | my $type = $1; | ||||
60 | my $caller_sym = $caller.'::'.$sym; | ||||
61 | my $export_sym = $exporter.'::'.$sym; | ||||
62 | *{$caller_sym} = | ||||
63 | $type eq '&' ? \&{$export_sym} : | ||||
64 | $type eq '$' ? \${$export_sym} : | ||||
65 | $type eq '@' ? \@{$export_sym} : | ||||
66 | $type eq '%' ? \%{$export_sym} : | ||||
67 | $type eq '*' ? *{$export_sym} : | ||||
68 | do { require Carp; Carp::croak("Can't export symbol: $type$sym") }; | ||||
69 | } | ||||
70 | } | ||||
71 | |||||
72 | |||||
73 | #"# | ||||
74 | sub _not_exported { | ||||
75 | my($thing, $exporter, $file, $line) = @_; | ||||
76 | die sprintf qq|"%s" is not exported by the %s module at %s line %d\n|, | ||||
77 | $thing, $exporter, $file, $line; | ||||
78 | } | ||||
79 | |||||
80 | 1 | 3µs | 1; | ||
81 | |||||
82 | __END__ | ||||
# spent 2µs within Exporter::Lite::CORE:subst which was called 2 times, avg 850ns/call:
# 2 times (2µs+0s) by Exporter::Lite::_export at line 56, avg 850ns/call |