Filename | /usr/share/perl5/Text/CSV.pm |
Statements | Executed 87 statements in 1.52ms |
Calls | P | F | Exclusive Time |
Inclusive Time |
Subroutine |
---|---|---|---|---|---|
1 | 1 | 1 | 86µs | 86µs | _set_methods | Text::CSV::
1 | 1 | 1 | 50µs | 7.18ms | _load_xs | Text::CSV::
1 | 1 | 1 | 26µs | 76µs | BEGIN@137 | Text::CSV::
1 | 1 | 1 | 12µs | 22µs | BEGIN@4 | Text::CSV::
1 | 1 | 1 | 10µs | 18µs | BEGIN@197 | Text::CSV::
1 | 1 | 1 | 7µs | 30µs | BEGIN@6 | Text::CSV::
1 | 1 | 1 | 3µs | 3µs | BEGIN@5 | Text::CSV::
1 | 1 | 1 | 3µs | 3µs | BEGIN@8 | Text::CSV::
1 | 1 | 1 | 2µs | 2µs | import | Text::CSV::
0 | 0 | 0 | 0s | 0s | AUTOLOAD | Text::CSV::
0 | 0 | 0 | 0s | 0s | _load_pp | Text::CSV::
0 | 0 | 0 | 0s | 0s | is_dynamic | Text::CSV::
0 | 0 | 0 | 0s | 0s | is_pp | Text::CSV::
0 | 0 | 0 | 0s | 0s | is_xs | Text::CSV::
0 | 0 | 0 | 0s | 0s | module | Text::CSV::
0 | 0 | 0 | 0s | 0s | new | Text::CSV::
0 | 0 | 0 | 0s | 0s | require_xs_version | Text::CSV::
Line | State ments |
Time on line |
Calls | Time in subs |
Code |
---|---|---|---|---|---|
1 | package Text::CSV; | ||||
2 | |||||
3 | |||||
4 | 2 | 22µs | 2 | 32µs | # spent 22µs (12+10) within Text::CSV::BEGIN@4 which was called:
# once (12µs+10µs) by C4::Members::Attributes::BEGIN@23 at line 4 # spent 22µs making 1 call to Text::CSV::BEGIN@4
# spent 10µs making 1 call to strict::import |
5 | 2 | 20µs | 1 | 3µs | # spent 3µs within Text::CSV::BEGIN@5 which was called:
# once (3µs+0s) by C4::Members::Attributes::BEGIN@23 at line 5 # spent 3µs making 1 call to Text::CSV::BEGIN@5 |
6 | 2 | 31µs | 2 | 54µs | # spent 30µs (7+24) within Text::CSV::BEGIN@6 which was called:
# once (7µs+24µs) by C4::Members::Attributes::BEGIN@23 at line 6 # spent 30µs making 1 call to Text::CSV::BEGIN@6
# spent 24µs making 1 call to vars::import |
7 | |||||
8 | # spent 3µs within Text::CSV::BEGIN@8 which was called:
# once (3µs+0s) by C4::Members::Attributes::BEGIN@23 at line 11 | ||||
9 | 1 | 300ns | $VERSION = '1.32'; | ||
10 | 1 | 3µs | $DEBUG = 0; | ||
11 | 1 | 892µs | 1 | 3µs | } # spent 3µs making 1 call to Text::CSV::BEGIN@8 |
12 | |||||
13 | # if use CSV_XS, requires version | ||||
14 | 1 | 500ns | my $Module_XS = 'Text::CSV_XS'; | ||
15 | 1 | 200ns | my $Module_PP = 'Text::CSV_PP'; | ||
16 | 1 | 100ns | my $XS_Version = '0.99'; | ||
17 | |||||
18 | 1 | 200ns | my $Is_Dynamic = 0; | ||
19 | |||||
20 | # used in _load_xs and _load_pp | ||||
21 | 1 | 100ns | my $Install_Dont_Die = 1; # When _load_xs fails to load XS, don't die. | ||
22 | 1 | 100ns | my $Install_Only = 2; # Don't call _set_methods() | ||
23 | |||||
24 | |||||
25 | 1 | 3µs | my @PublicMethods = qw/ | ||
26 | version types quote_char escape_char sep_char eol always_quote binary allow_whitespace | ||||
27 | keep_meta_info allow_loose_quotes allow_loose_escapes verbatim meta_info is_quoted is_binary eof | ||||
28 | getline print parse combine fields string error_diag error_input status blank_is_undef empty_is_undef | ||||
29 | getline_hr column_names bind_columns auto_diag quote_space quote_null getline_all getline_hr_all | ||||
30 | is_missing quote_binary record_number print_hr | ||||
31 | PV IV NV | ||||
32 | /; | ||||
33 | # | ||||
34 | 1 | 400ns | my @UndocumentedXSMethods = qw/Combine Parse SetDiag/; | ||
35 | |||||
36 | 1 | 200ns | my @UndocumentedPPMethods = qw//; # Currently empty | ||
37 | |||||
38 | |||||
39 | # Check the environment variable to decide worker module. | ||||
40 | |||||
41 | 1 | 500ns | unless ($Text::CSV::Worker) { | ||
42 | 1 | 100ns | $Text::CSV::DEBUG and Carp::carp("Check used worker module..."); | ||
43 | |||||
44 | 1 | 900ns | if ( exists $ENV{PERL_TEXT_CSV} ) { | ||
45 | if ($ENV{PERL_TEXT_CSV} eq '0' or $ENV{PERL_TEXT_CSV} eq 'Text::CSV_PP') { | ||||
46 | _load_pp(); | ||||
47 | } | ||||
48 | elsif ($ENV{PERL_TEXT_CSV} eq '1' or $ENV{PERL_TEXT_CSV} =~ /Text::CSV_XS\s*,\s*Text::CSV_PP/) { | ||||
49 | _load_xs($Install_Dont_Die) or _load_pp(); | ||||
50 | } | ||||
51 | elsif ($ENV{PERL_TEXT_CSV} eq '2' or $ENV{PERL_TEXT_CSV} eq 'Text::CSV_XS') { | ||||
52 | _load_xs(); | ||||
53 | } | ||||
54 | else { | ||||
55 | Carp::croak "The value of environmental variable 'PERL_TEXT_CSV' is invalid."; | ||||
56 | } | ||||
57 | } | ||||
58 | else { | ||||
59 | 1 | 2µs | 1 | 7.18ms | _load_xs($Install_Dont_Die) or _load_pp(); # spent 7.18ms making 1 call to Text::CSV::_load_xs |
60 | } | ||||
61 | |||||
62 | } | ||||
63 | |||||
- - | |||||
66 | # spent 2µs within Text::CSV::import which was called:
# once (2µs+0s) by C4::Members::Attributes::BEGIN@23 at line 23 of C4/Members/Attributes.pm | ||||
67 | 1 | 3µs | my ($class, $option) = @_; | ||
68 | } | ||||
69 | |||||
- - | |||||
72 | sub new { # normal mode | ||||
73 | my $proto = shift; | ||||
74 | my $class = ref($proto) || $proto; | ||||
75 | |||||
76 | unless ( $proto ) { # for Text::CSV_XS/PP::new(0); | ||||
77 | return eval qq| $Text::CSV::Worker\::new( \$proto ) |; | ||||
78 | } | ||||
79 | |||||
80 | #if (ref $_[0] and $_[0]->{module}) { | ||||
81 | # Carp::croak("Can't set 'module' in non dynamic mode."); | ||||
82 | #} | ||||
83 | |||||
84 | if ( my $obj = $Text::CSV::Worker->new(@_) ) { | ||||
85 | $obj->{_MODULE} = $Text::CSV::Worker; | ||||
86 | bless $obj, $class; | ||||
87 | return $obj; | ||||
88 | } | ||||
89 | else { | ||||
90 | return; | ||||
91 | } | ||||
92 | |||||
93 | |||||
94 | } | ||||
95 | |||||
96 | |||||
97 | sub require_xs_version { $XS_Version; } | ||||
98 | |||||
99 | |||||
100 | sub module { | ||||
101 | my $proto = shift; | ||||
102 | return !ref($proto) ? $Text::CSV::Worker | ||||
103 | : ref($proto->{_MODULE}) ? ref($proto->{_MODULE}) : $proto->{_MODULE}; | ||||
104 | } | ||||
105 | |||||
106 | 1 | 2µs | *backend = *module; | ||
107 | |||||
108 | |||||
109 | sub is_xs { | ||||
110 | return $_[0]->module eq $Module_XS; | ||||
111 | } | ||||
112 | |||||
113 | |||||
114 | sub is_pp { | ||||
115 | return $_[0]->module eq $Module_PP; | ||||
116 | } | ||||
117 | |||||
118 | |||||
119 | sub is_dynamic { $Is_Dynamic; } | ||||
120 | |||||
121 | |||||
122 | sub AUTOLOAD { | ||||
123 | my $self = $_[0]; | ||||
124 | my $attr = $Text::CSV::AUTOLOAD; | ||||
125 | $attr =~ s/.*:://; | ||||
126 | |||||
127 | return if $attr =~ /^[A-Z]+$/; | ||||
128 | Carp::croak( "Can't locate method $attr" ) unless $attr =~ /^_/; | ||||
129 | |||||
130 | my $pkg = $Text::CSV::Worker; | ||||
131 | |||||
132 | my $method = "$pkg\::$attr"; | ||||
133 | |||||
134 | $Text::CSV::DEBUG and Carp::carp("'$attr' is private method, so try to autoload..."); | ||||
135 | |||||
136 | local $^W; | ||||
137 | 2 | 260µs | 2 | 126µs | # spent 76µs (26+50) within Text::CSV::BEGIN@137 which was called:
# once (26µs+50µs) by C4::Members::Attributes::BEGIN@23 at line 137 # spent 76µs making 1 call to Text::CSV::BEGIN@137
# spent 50µs making 1 call to strict::unimport |
138 | |||||
139 | *{"Text::CSV::$attr"} = *{"$pkg\::$attr"}; | ||||
140 | |||||
141 | goto &$attr; | ||||
142 | } | ||||
143 | |||||
- - | |||||
146 | # spent 7.18ms (50µs+7.13) within Text::CSV::_load_xs which was called:
# once (50µs+7.13ms) by C4::Members::Attributes::BEGIN@23 at line 59 | ||||
147 | 1 | 200ns | my $opt = shift; | ||
148 | |||||
149 | 1 | 100ns | $Text::CSV::DEBUG and Carp::carp "Load $Module_XS."; | ||
150 | |||||
151 | 1 | 27µs | eval qq| use $Module_XS $XS_Version |; # spent 732µs executing statements in string eval # includes 5.97ms spent executing 1 call to 1 sub defined therein. | ||
152 | |||||
153 | 1 | 200ns | if ($@) { | ||
154 | if (defined $opt and $opt & $Install_Dont_Die) { | ||||
155 | $Text::CSV::DEBUG and Carp::carp "Can't load $Module_XS...($@)"; | ||||
156 | return 0; | ||||
157 | } | ||||
158 | Carp::croak $@; | ||||
159 | } | ||||
160 | |||||
161 | 1 | 6µs | push @Text::CSV::ISA, 'Text::CSV_XS'; | ||
162 | |||||
163 | 1 | 1µs | unless (defined $opt and $opt & $Install_Only) { | ||
164 | 1 | 2µs | 1 | 86µs | _set_methods( $Text::CSV::Worker = $Module_XS ); # spent 86µs making 1 call to Text::CSV::_set_methods |
165 | } | ||||
166 | |||||
167 | 1 | 2µs | return 1; | ||
168 | }; | ||||
169 | |||||
170 | |||||
171 | sub _load_pp { | ||||
172 | my $opt = shift; | ||||
173 | |||||
174 | $Text::CSV::DEBUG and Carp::carp "Load $Module_PP."; | ||||
175 | |||||
176 | eval qq| require $Module_PP |; | ||||
177 | if ($@) { | ||||
178 | Carp::croak $@; | ||||
179 | } | ||||
180 | |||||
181 | push @Text::CSV::ISA, 'Text::CSV_PP'; | ||||
182 | |||||
183 | unless (defined $opt and $opt & $Install_Only) { | ||||
184 | _set_methods( $Text::CSV::Worker = $Module_PP ); | ||||
185 | } | ||||
186 | }; | ||||
187 | |||||
- - | |||||
191 | # spent 86µs within Text::CSV::_set_methods which was called:
# once (86µs+0s) by Text::CSV::_load_xs at line 164 | ||||
192 | 1 | 400ns | my $class = shift; | ||
193 | |||||
194 | #return; | ||||
195 | |||||
196 | 1 | 3µs | local $^W; | ||
197 | 2 | 129µs | 2 | 26µs | # spent 18µs (10+8) within Text::CSV::BEGIN@197 which was called:
# once (10µs+8µs) by C4::Members::Attributes::BEGIN@23 at line 197 # spent 18µs making 1 call to Text::CSV::BEGIN@197
# spent 8µs making 1 call to strict::unimport |
198 | |||||
199 | 1 | 900ns | for my $method (@PublicMethods) { | ||
200 | 43 | 73µs | *{"Text::CSV::$method"} = \&{"$class\::$method"}; | ||
201 | } | ||||
202 | |||||
203 | 1 | 1µs | if ($Text::CSV::Worker eq $Module_XS) { | ||
204 | for my $method (@UndocumentedXSMethods) { | ||||
205 | 3 | 5µs | *{"Text::CSV::$method"} = \&{"$Module_XS\::$method"}; | ||
206 | } | ||||
207 | } | ||||
208 | |||||
209 | 1 | 5µs | if ($Text::CSV::Worker eq $Module_PP) { | ||
210 | for my $method (@UndocumentedPPMethods) { | ||||
211 | *{"Text::CSV::$method"} = \&{"$Module_PP\::$method"}; | ||||
212 | } | ||||
213 | } | ||||
214 | |||||
215 | } | ||||
216 | |||||
- - | |||||
219 | 1 | 18µs | 1; | ||
220 | __END__ |