← Index
NYTProf Performance Profile   « line view »
For Makefile.PL
  Run on Sun Mar 1 16:04:44 2015
Reported on Sun Mar 1 16:09:02 2015

FilenameC:/tmp64ng/perl/lib/Parse/CPAN/Meta.pm
StatementsExecuted 558 statements in 15.6ms
Subroutines
Calls P F Exclusive
Time
Inclusive
Time
Subroutine
732115.6ms31.2msParse::CPAN::Meta::::_can_load Parse::CPAN::Meta::_can_load
1110s0sCPAN::Meta::Converter::::BEGIN@1.7CPAN::Meta::Converter::BEGIN@1.7
1110s0sCPAN::Meta::Converter::::BEGIN@2.8CPAN::Meta::Converter::BEGIN@2.8
1110s0sParse::CPAN::Meta::::BEGIN@45 Parse::CPAN::Meta::BEGIN@45
1110s0sParse::CPAN::Meta::::BEGIN@7 Parse::CPAN::Meta::BEGIN@7
1110s0sParse::CPAN::Meta::::BEGIN@8 Parse::CPAN::Meta::BEGIN@8
2110s0sParse::CPAN::Meta::::CORE:match Parse::CPAN::Meta::CORE:match (opcode)
1110s0sParse::CPAN::Meta::::CORE:open Parse::CPAN::Meta::CORE:open (opcode)
1110s0sParse::CPAN::Meta::::CORE:readline Parse::CPAN::Meta::CORE:readline (opcode)
73110s0sParse::CPAN::Meta::::CORE:subst Parse::CPAN::Meta::CORE:subst (opcode)
0000s0sParse::CPAN::Meta::::Load Parse::CPAN::Meta::Load
0000s0sParse::CPAN::Meta::::LoadFile Parse::CPAN::Meta::LoadFile
1110s0sParse::CPAN::Meta::::_slurp Parse::CPAN::Meta::_slurp
64330s15.6msParse::CPAN::Meta::::json_backend Parse::CPAN::Meta::json_backend
1110s0sParse::CPAN::Meta::::load_file Parse::CPAN::Meta::load_file
1110s0sParse::CPAN::Meta::::load_json_string Parse::CPAN::Meta::load_json_string
0000s0sParse::CPAN::Meta::::load_string Parse::CPAN::Meta::load_string
0000s0sParse::CPAN::Meta::::load_yaml_string Parse::CPAN::Meta::load_yaml_string
9110s15.6msParse::CPAN::Meta::::yaml_backend Parse::CPAN::Meta::yaml_backend
Call graph for these subroutines as a Graphviz dot language file.
Line State
ments
Time
on line
Calls Time
in subs
Code
120s10s
# spent 0s within CPAN::Meta::Converter::BEGIN@1.7 which was called: # once (0s+0s) by CPAN::Meta::Converter::BEGIN@27 at line 1
use 5.008001;
# spent 0s making 1 call to CPAN::Meta::Converter::BEGIN@1.7
220s20s
# spent 0s within CPAN::Meta::Converter::BEGIN@2.8 which was called: # once (0s+0s) by CPAN::Meta::Converter::BEGIN@27 at line 2
use strict;
# spent 0s making 1 call to CPAN::Meta::Converter::BEGIN@2.8 # spent 0s making 1 call to strict::import
3package Parse::CPAN::Meta;
4# ABSTRACT: Parse META.yml and META.json CPAN metadata files
510sour $VERSION = '1.4414'; # VERSION
6
720s20s
# spent 0s within Parse::CPAN::Meta::BEGIN@7 which was called: # once (0s+0s) by CPAN::Meta::Converter::BEGIN@27 at line 7
use Exporter;
# spent 0s making 1 call to Exporter::import # spent 0s making 1 call to Parse::CPAN::Meta::BEGIN@7
820s20s
# spent 0s within Parse::CPAN::Meta::BEGIN@8 which was called: # once (0s+0s) by CPAN::Meta::Converter::BEGIN@27 at line 8
use Carp 'croak';
# spent 0s making 1 call to Exporter::import # spent 0s making 1 call to Parse::CPAN::Meta::BEGIN@8
9
1010sour @ISA = qw/Exporter/;
1110sour @EXPORT_OK = qw/Load LoadFile/;
12
13
# spent 0s within Parse::CPAN::Meta::load_file which was called: # once (0s+0s) by CPAN::Meta::load_file at line 300 of CPAN/Meta.pm
sub load_file {
1410s my ($class, $filename) = @_;
15
1610s10s my $meta = _slurp($filename);
# spent 0s making 1 call to Parse::CPAN::Meta::_slurp
17
1810s30s if ($filename =~ /\.ya?ml$/) {
# spent 0s making 2 calls to Parse::CPAN::Meta::CORE:match, avg 0s/call # spent 0s making 1 call to Parse::CPAN::Meta::load_json_string
19 return $class->load_yaml_string($meta);
20 }
21 elsif ($filename =~ /\.json$/) {
22 return $class->load_json_string($meta);
23 }
24 else {
25 $class->load_string($meta); # try to detect yaml/json
26 }
27}
28
29sub load_string {
30 my ($class, $string) = @_;
31 if ( $string =~ /^---/ ) { # looks like YAML
32 return $class->load_yaml_string($string);
33 }
34 elsif ( $string =~ /^\s*\{/ ) { # looks like JSON
35 return $class->load_json_string($string);
36 }
37 else { # maybe doc-marker-free YAML
38 return $class->load_yaml_string($string);
39 }
40}
41
42sub load_yaml_string {
43 my ($class, $string) = @_;
44 my $backend = $class->yaml_backend();
4520s20s
# spent 0s within Parse::CPAN::Meta::BEGIN@45 which was called: # once (0s+0s) by CPAN::Meta::Converter::BEGIN@27 at line 45
my $data = eval { no strict 'refs'; &{"$backend\::Load"}($string) };
# spent 0s making 1 call to Parse::CPAN::Meta::BEGIN@45 # spent 0s making 1 call to strict::unimport
46 croak $@ if $@;
47 return $data || {}; # in case document was valid but empty
48}
49
50
# spent 0s within Parse::CPAN::Meta::load_json_string which was called: # once (0s+0s) by Parse::CPAN::Meta::load_file at line 18
sub load_json_string {
5110s my ($class, $string) = @_;
5220s30s my $data = eval { $class->json_backend()->new->decode($string) };
# spent 0s making 1 call to JSON::PP::decode # spent 0s making 1 call to JSON::PP::new # spent 0s making 1 call to Parse::CPAN::Meta::json_backend
5310s croak $@ if $@;
5410s return $data || {};
55}
56
57
# spent 15.6ms (0s+15.6) within Parse::CPAN::Meta::yaml_backend which was called 9 times, avg 1.73ms/call: # 9 times (0s+15.6ms) by CPAN::Meta::as_string at line 615 of CPAN/Meta.pm, avg 1.73ms/call
sub yaml_backend {
5890s if (! defined $ENV{PERL_YAML_BACKEND} ) {
5990s915.6ms _can_load( 'CPAN::Meta::YAML', 0.011 )
# spent 15.6ms making 9 calls to Parse::CPAN::Meta::_can_load, avg 1.73ms/call
60 or croak "CPAN::Meta::YAML 0.011 is not available\n";
6190s return "CPAN::Meta::YAML";
62 }
63 else {
64 my $backend = $ENV{PERL_YAML_BACKEND};
65 _can_load( $backend )
66 or croak "Could not load PERL_YAML_BACKEND '$backend'\n";
67 $backend->can("Load")
68 or croak "PERL_YAML_BACKEND '$backend' does not implement Load()\n";
69 return $backend;
70 }
71}
72
73
# spent 15.6ms (0s+15.6) within Parse::CPAN::Meta::json_backend which was called 64 times, avg 244µs/call: # 54 times (0s+15.6ms) by CPAN::Meta::Converter::_dclone at line 56 of CPAN/Meta/Converter.pm, avg 289µs/call # 9 times (0s+0s) by CPAN::Meta::as_string at line 611 of CPAN/Meta.pm, avg 0s/call # once (0s+0s) by Parse::CPAN::Meta::load_json_string at line 52
sub json_backend {
74640s if (! $ENV{PERL_JSON_BACKEND} or $ENV{PERL_JSON_BACKEND} eq 'JSON::PP') {
75640s6415.6ms _can_load( 'JSON::PP' => 2.27103 )
# spent 15.6ms making 64 calls to Parse::CPAN::Meta::_can_load, avg 244µs/call
76 or croak "JSON::PP 2.27103 is not available\n";
77640s return 'JSON::PP';
78 }
79 else {
80 _can_load( 'JSON' => 2.5 )
81 or croak "JSON 2.5 is required for " .
82 "\$ENV{PERL_JSON_BACKEND} = '$ENV{PERL_JSON_BACKEND}'\n";
83 return "JSON";
84 }
85}
86
87
# spent 0s within Parse::CPAN::Meta::_slurp which was called: # once (0s+0s) by Parse::CPAN::Meta::load_file at line 16
sub _slurp {
8810s require Encode;
8910s10s open my $fh, "<:raw", "$_[0]" ## no critic
# spent 0s making 1 call to Parse::CPAN::Meta::CORE:open
90 or die "can't open $_[0] for reading: $!";
9130s10s my $content = do { local $/; <$fh> };
# spent 0s making 1 call to Parse::CPAN::Meta::CORE:readline
9210s20s $content = Encode::decode('UTF-8', $content, Encode::PERLQQ());
# spent 0s making 1 call to Encode::PERLQQ # spent 0s making 1 call to Encode::decode
9310s return $content;
94}
95
96
# spent 31.2ms (15.6+15.6) within Parse::CPAN::Meta::_can_load which was called 73 times, avg 427µs/call: # 64 times (0s+15.6ms) by Parse::CPAN::Meta::json_backend at line 75, avg 244µs/call # 9 times (15.6ms+0s) by Parse::CPAN::Meta::yaml_backend at line 59, avg 1.73ms/call
sub _can_load {
97730s my ($module, $version) = @_;
98730s730s (my $file = $module) =~ s{::}{/}g;
# spent 0s making 73 calls to Parse::CPAN::Meta::CORE:subst, avg 0s/call
99730s $file .= ".pm";
100730s return 1 if $INC{$file};
10120s return 0 if exists $INC{$file}; # prior load failed
102615.6ms eval { require $file; 1 }
103 or return 0;
10420s if ( defined $version ) {
10560s20s eval { $module->VERSION($version); 1 }
# spent 0s making 2 calls to version::vxs::_VERSION, avg 0s/call
106 or return 0;
107 }
10820s return 1;
109}
110
111# Kept for backwards compatibility only
112# Create an object from a file
113sub LoadFile ($) {
114 return Load(_slurp(shift));
115}
116
117# Parse a document from a string.
118sub Load ($) {
119 require CPAN::Meta::YAML;
120 my $object = eval { CPAN::Meta::YAML::Load(shift) };
121 croak $@ if $@;
122 return $object;
123}
124
12510s1;
126
127__END__
 
# spent 0s within Parse::CPAN::Meta::CORE:match which was called 2 times, avg 0s/call: # 2 times (0s+0s) by Parse::CPAN::Meta::load_file at line 18, avg 0s/call
sub Parse::CPAN::Meta::CORE:match; # opcode
# spent 0s within Parse::CPAN::Meta::CORE:open which was called: # once (0s+0s) by Parse::CPAN::Meta::_slurp at line 89
sub Parse::CPAN::Meta::CORE:open; # opcode
# spent 0s within Parse::CPAN::Meta::CORE:readline which was called: # once (0s+0s) by Parse::CPAN::Meta::_slurp at line 91
sub Parse::CPAN::Meta::CORE:readline; # opcode
# spent 0s within Parse::CPAN::Meta::CORE:subst which was called 73 times, avg 0s/call: # 73 times (0s+0s) by Parse::CPAN::Meta::_can_load at line 98, avg 0s/call
sub Parse::CPAN::Meta::CORE:subst; # opcode