Filename | /Users/ether/.perlbrew/libs/36.0@std/lib/perl5/YAML/PP/Loader.pm |
Statements | Executed 39 statements in 1.75ms |
Calls | P | F | Exclusive Time |
Inclusive Time |
Subroutine |
---|---|---|---|---|---|
1 | 1 | 1 | 6.30ms | 18.8ms | BEGIN@8 | YAML::PP::Loader::
1 | 1 | 1 | 2.24ms | 2.44ms | BEGIN@9 | YAML::PP::Loader::
1 | 1 | 1 | 28µs | 114µs | new | YAML::PP::Loader::
1 | 1 | 1 | 27µs | 30µs | BEGIN@2.285 | YAML::PP::
1 | 1 | 1 | 17µs | 5.21s | load_file | YAML::PP::Loader::
1 | 1 | 1 | 13µs | 5.21s | load | YAML::PP::Loader::
1 | 1 | 1 | 6µs | 29µs | BEGIN@3 | YAML::PP::
1 | 1 | 1 | 6µs | 6µs | BEGIN@10 | YAML::PP::Loader::
2 | 2 | 1 | 3µs | 3µs | parser | YAML::PP::Loader::
3 | 3 | 1 | 2µs | 2µs | __ANON__ (xsub) | YAML::PP::Loader::
0 | 0 | 0 | 0s | 0s | clone | YAML::PP::Loader::
1 | 1 | 1 | 0s | 0s | constructor | YAML::PP::Loader::
0 | 0 | 0 | 0s | 0s | filename | YAML::PP::Loader::
0 | 0 | 0 | 0s | 0s | load_string | YAML::PP::Loader::
Line | State ments |
Time on line |
Calls | Time in subs |
Code |
---|---|---|---|---|---|
1 | # ABSTRACT: Load YAML into data with Parser and Constructor | ||||
2 | 2 | 52µs | 2 | 33µs | # spent 30µs (27+3) within YAML::PP::BEGIN@2.285 which was called:
# once (27µs+3µs) by YAML::PP::BEGIN@10 at line 2 # spent 30µs making 1 call to YAML::PP::BEGIN@2.285
# spent 3µs making 1 call to strict::import |
3 | 2 | 32µs | 2 | 52µs | # spent 29µs (6+23) within YAML::PP::BEGIN@3 which was called:
# once (6µs+23µs) by YAML::PP::BEGIN@10 at line 3 # spent 29µs making 1 call to YAML::PP::BEGIN@3
# spent 23µs making 1 call to warnings::import |
4 | package YAML::PP::Loader; | ||||
5 | |||||
6 | 1 | 1µs | our $VERSION = '0.035'; # VERSION | ||
7 | |||||
8 | 2 | 839µs | 2 | 18.8ms | # spent 18.8ms (6.30+12.5) within YAML::PP::Loader::BEGIN@8 which was called:
# once (6.30ms+12.5ms) by YAML::PP::BEGIN@10 at line 8 # spent 18.8ms making 1 call to YAML::PP::Loader::BEGIN@8
# spent 2µs making 1 call to YAML::PP::Loader::__ANON__ |
9 | 2 | 497µs | 2 | 2.44ms | # spent 2.44ms (2.24+203µs) within YAML::PP::Loader::BEGIN@9 which was called:
# once (2.24ms+203µs) by YAML::PP::BEGIN@10 at line 9 # spent 2.44ms making 1 call to YAML::PP::Loader::BEGIN@9
# spent 0s making 1 call to YAML::PP::Loader::__ANON__ |
10 | 2 | 285µs | 2 | 6µs | # spent 6µs within YAML::PP::Loader::BEGIN@10 which was called:
# once (6µs+0s) by YAML::PP::BEGIN@10 at line 10 # spent 6µs making 1 call to YAML::PP::Loader::BEGIN@10
# spent 0s making 1 call to YAML::PP::Loader::__ANON__ |
11 | |||||
12 | # spent 114µs (28+86) within YAML::PP::Loader::new which was called:
# once (28µs+86µs) by YAML::PP::new at line 65 of YAML/PP.pm | ||||
13 | 1 | 3µs | my ($class, %args) = @_; | ||
14 | |||||
15 | 1 | 1µs | my $cyclic_refs = delete $args{cyclic_refs} || 'allow'; | ||
16 | 1 | 0s | my $default_yaml_version = delete $args{default_yaml_version} || '1.2'; | ||
17 | 1 | 0s | my $preserve = delete $args{preserve}; | ||
18 | 1 | 0s | my $duplicate_keys = delete $args{duplicate_keys}; | ||
19 | 1 | 0s | my $schemas = delete $args{schemas}; | ||
20 | 1 | 0s | $schemas ||= { | ||
21 | '1.2' => YAML::PP->default_schema( | ||||
22 | boolean => 'perl', | ||||
23 | ) | ||||
24 | }; | ||||
25 | |||||
26 | 1 | 4µs | 1 | 52µs | my $constructor = delete $args{constructor} || YAML::PP::Constructor->new( # spent 52µs making 1 call to YAML::PP::Constructor::new |
27 | schemas => $schemas, | ||||
28 | cyclic_refs => $cyclic_refs, | ||||
29 | default_yaml_version => $default_yaml_version, | ||||
30 | preserve => $preserve, | ||||
31 | duplicate_keys => $duplicate_keys, | ||||
32 | ); | ||||
33 | 1 | 0s | my $parser = delete $args{parser}; | ||
34 | 1 | 3µs | 1 | 29µs | unless ($parser) { # spent 29µs making 1 call to YAML::PP::Parser::new |
35 | $parser = YAML::PP::Parser->new( | ||||
36 | default_yaml_version => $default_yaml_version, | ||||
37 | ); | ||||
38 | } | ||||
39 | 1 | 3µs | 2 | 5µs | unless ($parser->receiver) { # spent 4µs making 1 call to YAML::PP::Parser::set_receiver
# spent 1µs making 1 call to YAML::PP::Parser::receiver |
40 | $parser->set_receiver($constructor); | ||||
41 | } | ||||
42 | |||||
43 | 1 | 0s | if (keys %args) { | ||
44 | die "Unexpected arguments: " . join ', ', sort keys %args; | ||||
45 | } | ||||
46 | 1 | 1µs | my $self = bless { | ||
47 | parser => $parser, | ||||
48 | constructor => $constructor, | ||||
49 | }, $class; | ||||
50 | 1 | 2µs | return $self; | ||
51 | } | ||||
52 | |||||
53 | sub clone { | ||||
54 | my ($self) = @_; | ||||
55 | my $clone = { | ||||
56 | parser => $self->parser->clone, | ||||
57 | constructor => $self->constructor->clone, | ||||
58 | }; | ||||
59 | bless $clone, ref $self; | ||||
60 | $clone->parser->set_receiver($clone->constructor); | ||||
61 | return $clone; | ||||
62 | } | ||||
63 | |||||
64 | 2 | 4µs | sub parser { return $_[0]->{parser} } | ||
65 | 1 | 1µs | # spent 0s within YAML::PP::Loader::constructor which was called:
# once (0s+0s) by YAML::PP::Loader::load at line 91 | ||
66 | |||||
67 | sub filename { | ||||
68 | my ($self) = @_; | ||||
69 | my $reader = $self->parser->reader; | ||||
70 | if ($reader->isa('YAML::PP::Reader::File')) { | ||||
71 | return $reader->input; | ||||
72 | } | ||||
73 | die "Reader is not a YAML::PP::Reader::File"; | ||||
74 | } | ||||
75 | |||||
76 | sub load_string { | ||||
77 | my ($self, $yaml) = @_; | ||||
78 | $self->parser->set_reader(YAML::PP::Reader->new( input => $yaml )); | ||||
79 | $self->load(); | ||||
80 | } | ||||
81 | |||||
82 | # spent 5.21s (17µs+5.21) within YAML::PP::Loader::load_file which was called:
# once (17µs+5.21s) by YAML::PP::load_file at line 154 of YAML/PP.pm | ||||
83 | 1 | 1µs | my ($self, $file) = @_; | ||
84 | 1 | 5µs | 3 | 16µs | $self->parser->set_reader(YAML::PP::Reader::File->new( input => $file )); # spent 12µs making 1 call to YAML::PP::Parser::set_reader
# spent 2µs making 1 call to YAML::PP::Loader::parser
# spent 2µs making 1 call to YAML::PP::Reader::new |
85 | 1 | 5µs | 1 | 5.21s | $self->load(); # spent 5.21s making 1 call to YAML::PP::Loader::load |
86 | } | ||||
87 | |||||
88 | # spent 5.21s (13µs+5.21) within YAML::PP::Loader::load which was called:
# once (13µs+5.21s) by YAML::PP::Loader::load_file at line 85 | ||||
89 | 1 | 0s | my ($self) = @_; | ||
90 | 1 | 1µs | 1 | 1µs | my $parser = $self->parser; # spent 1µs making 1 call to YAML::PP::Loader::parser |
91 | 1 | 0s | 1 | 0s | my $constructor = $self->constructor; # spent 0s making 1 call to YAML::PP::Loader::constructor |
92 | |||||
93 | 1 | 1µs | 1 | 17µs | $constructor->init; # spent 17µs making 1 call to YAML::PP::Constructor::init |
94 | 1 | 3µs | 1 | 5.21s | $parser->parse(); # spent 5.21s making 1 call to YAML::PP::Parser::parse |
95 | |||||
96 | 1 | 1µs | 1 | 0s | my $docs = $constructor->docs; # spent 0s making 1 call to YAML::PP::Constructor::docs |
97 | 1 | 6µs | return wantarray ? @$docs : $docs->[0]; | ||
98 | } | ||||
99 | |||||
100 | |||||
101 | 1 | 3µs | 1; | ||
sub YAML::PP::Loader::__ANON__; # xsub |