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