| Filename | /home/hejohns/perl5/lib/perl5/Text/CSV.pm |
| Statements | Executed 44 statements in 533µs |
| Calls | P | F | Exclusive Time |
Inclusive Time |
Subroutine |
|---|---|---|---|---|---|
| 1 | 1 | 1 | 55µs | 6.56ms | Text::CSV::_load |
| 1 | 1 | 1 | 8µs | 10µs | Text::CSV::BEGIN@4 |
| 1 | 1 | 1 | 6µs | 10µs | Text::CSV::BEGIN@122 |
| 1 | 1 | 1 | 4µs | 29µs | Text::CSV::BEGIN@7 |
| 1 | 1 | 1 | 4µs | 9µs | Text::CSV::BEGIN@5 |
| 1 | 1 | 1 | 2µs | 6.57ms | Text::CSV::_load_xs |
| 1 | 1 | 1 | 2µs | 2µs | Text::CSV::BEGIN@11 |
| 1 | 1 | 1 | 1µs | 1µs | Text::CSV::BEGIN@6 |
| 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 | 2 | 18µs | 2 | 11µs | # spent 10µs (8+2) within Text::CSV::BEGIN@4 which was called:
# once (8µs+2µs) by main::BEGIN@20 at line 4 # spent 10µs making 1 call to Text::CSV::BEGIN@4
# spent 2µs making 1 call to strict::import |
| 5 | 2 | 12µs | 2 | 14µs | # spent 9µs (4+5) within Text::CSV::BEGIN@5 which was called:
# once (4µs+5µs) by main::BEGIN@20 at line 5 # spent 9µs making 1 call to Text::CSV::BEGIN@5
# spent 5µs making 1 call to Exporter::import |
| 6 | 2 | 13µs | 1 | 1µs | # spent 1µs within Text::CSV::BEGIN@6 which was called:
# once (1µs+0s) by main::BEGIN@20 at line 6 # spent 1µs making 1 call to Text::CSV::BEGIN@6 |
| 7 | 2 | 32µs | 2 | 54µs | # spent 29µs (4+25) within Text::CSV::BEGIN@7 which was called:
# once (4µs+25µs) by main::BEGIN@20 at line 7 # spent 29µs making 1 call to Text::CSV::BEGIN@7
# spent 25µs making 1 call to vars::import |
| 8 | 1 | 6µs | @ISA = qw( Exporter ); | ||
| 9 | 1 | 300ns | @EXPORT_OK = qw( csv ); | ||
| 10 | |||||
| 11 | # spent 2µs within Text::CSV::BEGIN@11 which was called:
# once (2µs+0s) by main::BEGIN@20 at line 14 | ||||
| 12 | 1 | 300ns | $VERSION = '2.01'; | ||
| 13 | 1 | 2µs | $DEBUG = 0; | ||
| 14 | 1 | 304µs | 1 | 2µs | } # spent 2µs making 1 call to Text::CSV::BEGIN@11 |
| 15 | |||||
| 16 | # if use CSV_XS, requires version | ||||
| 17 | 1 | 200ns | my $Module_XS = 'Text::CSV_XS'; | ||
| 18 | 1 | 100ns | my $Module_PP = 'Text::CSV_PP'; | ||
| 19 | 1 | 100ns | my $XS_Version = '1.46'; | ||
| 20 | |||||
| 21 | 1 | 100ns | my $Is_Dynamic = 0; | ||
| 22 | |||||
| 23 | 1 | 600ns | my @PublicMethods = qw/ | ||
| 24 | version error_diag error_input | ||||
| 25 | known_attributes csv | ||||
| 26 | PV IV NV | ||||
| 27 | /; | ||||
| 28 | # | ||||
| 29 | |||||
| 30 | # Check the environment variable to decide worker module. | ||||
| 31 | |||||
| 32 | 1 | 300ns | unless ($Text::CSV::Worker) { | ||
| 33 | 1 | 100ns | $Text::CSV::DEBUG and Carp::carp("Check used worker module..."); | ||
| 34 | |||||
| 35 | 1 | 500ns | if ( exists $ENV{PERL_TEXT_CSV} ) { | ||
| 36 | if ($ENV{PERL_TEXT_CSV} eq '0' or $ENV{PERL_TEXT_CSV} eq 'Text::CSV_PP') { | ||||
| 37 | _load_pp() or Carp::croak $@; | ||||
| 38 | } | ||||
| 39 | elsif ($ENV{PERL_TEXT_CSV} eq '1' or $ENV{PERL_TEXT_CSV} =~ /Text::CSV_XS\s*,\s*Text::CSV_PP/) { | ||||
| 40 | _load_xs() or _load_pp() or Carp::croak $@; | ||||
| 41 | } | ||||
| 42 | elsif ($ENV{PERL_TEXT_CSV} eq '2' or $ENV{PERL_TEXT_CSV} eq 'Text::CSV_XS') { | ||||
| 43 | _load_xs() or Carp::croak $@; | ||||
| 44 | } | ||||
| 45 | else { | ||||
| 46 | Carp::croak "The value of environmental variable 'PERL_TEXT_CSV' is invalid."; | ||||
| 47 | } | ||||
| 48 | } | ||||
| 49 | else { | ||||
| 50 | 1 | 900ns | 1 | 6.57ms | _load_xs() or _load_pp() or Carp::croak $@; # spent 6.57ms making 1 call to Text::CSV::_load_xs |
| 51 | } | ||||
| 52 | |||||
| 53 | } | ||||
| 54 | |||||
| 55 | sub new { # normal mode | ||||
| 56 | my $proto = shift; | ||||
| 57 | my $class = ref($proto) || $proto; | ||||
| 58 | |||||
| 59 | unless ( $proto ) { # for Text::CSV_XS/PP::new(0); | ||||
| 60 | return eval qq| $Text::CSV::Worker\::new( \$proto ) |; | ||||
| 61 | } | ||||
| 62 | |||||
| 63 | #if (ref $_[0] and $_[0]->{module}) { | ||||
| 64 | # Carp::croak("Can't set 'module' in non dynamic mode."); | ||||
| 65 | #} | ||||
| 66 | |||||
| 67 | if ( my $obj = $Text::CSV::Worker->new(@_) ) { | ||||
| 68 | $obj->{_MODULE} = $Text::CSV::Worker; | ||||
| 69 | bless $obj, $class; | ||||
| 70 | return $obj; | ||||
| 71 | } | ||||
| 72 | else { | ||||
| 73 | return; | ||||
| 74 | } | ||||
| 75 | |||||
| 76 | |||||
| 77 | } | ||||
| 78 | |||||
| 79 | |||||
| 80 | sub require_xs_version { $XS_Version; } | ||||
| 81 | |||||
| 82 | |||||
| 83 | sub module { | ||||
| 84 | my $proto = shift; | ||||
| 85 | return !ref($proto) ? $Text::CSV::Worker | ||||
| 86 | : ref($proto->{_MODULE}) ? ref($proto->{_MODULE}) : $proto->{_MODULE}; | ||||
| 87 | } | ||||
| 88 | |||||
| 89 | 1 | 1µs | *backend = *module; | ||
| 90 | |||||
| 91 | |||||
| 92 | sub is_xs { | ||||
| 93 | return $_[0]->module eq $Module_XS; | ||||
| 94 | } | ||||
| 95 | |||||
| 96 | |||||
| 97 | sub is_pp { | ||||
| 98 | return $_[0]->module eq $Module_PP; | ||||
| 99 | } | ||||
| 100 | |||||
| 101 | |||||
| 102 | sub is_dynamic { $Is_Dynamic; } | ||||
| 103 | |||||
| 104 | 1 | 2µs | 1 | 6.56ms | # spent 6.57ms (2µs+6.56) within Text::CSV::_load_xs which was called:
# once (2µs+6.56ms) by main::BEGIN@20 at line 50 # spent 6.56ms making 1 call to Text::CSV::_load |
| 105 | |||||
| 106 | sub _load_pp { _load($Module_PP) } | ||||
| 107 | |||||
| 108 | # spent 6.56ms (55µs+6.51) within Text::CSV::_load which was called:
# once (55µs+6.51ms) by Text::CSV::_load_xs at line 104 | ||||
| 109 | 1 | 300ns | my ($module, $version) = @_; | ||
| 110 | 1 | 200ns | $version ||= ''; | ||
| 111 | |||||
| 112 | 1 | 0s | $Text::CSV::DEBUG and Carp::carp "Load $module."; | ||
| 113 | |||||
| 114 | 1 | 27µs | eval qq| use $module $version |; # spent 85µs executing statements in string eval # includes 6.21ms spent executing 1 call to 1 sub defined therein. | ||
| 115 | |||||
| 116 | 1 | 100ns | return if $@; | ||
| 117 | |||||
| 118 | 1 | 6µs | push @Text::CSV::ISA, $module; | ||
| 119 | 1 | 300ns | $Text::CSV::Worker = $module; | ||
| 120 | |||||
| 121 | 1 | 1µs | local $^W; | ||
| 122 | 2 | 76µs | 2 | 15µs | # spent 10µs (6+5) within Text::CSV::BEGIN@122 which was called:
# once (6µs+5µs) by main::BEGIN@20 at line 122 # spent 10µs making 1 call to Text::CSV::BEGIN@122
# spent 5µs making 1 call to strict::unimport |
| 123 | |||||
| 124 | 1 | 500ns | for my $method (@PublicMethods) { | ||
| 125 | 8 | 11µs | *{"Text::CSV::$method"} = \&{"$module\::$method"}; | ||
| 126 | } | ||||
| 127 | 1 | 2µs | return 1; | ||
| 128 | } | ||||
| 129 | |||||
| - - | |||||
| 132 | 1 | 15µs | 1; | ||
| 133 | __END__ |