Filename | /usr/lib/perl5/YAML/Syck.pm |
Statements | Executed 31 statements in 2.68ms |
Calls | P | F | Exclusive Time |
Inclusive Time |
Subroutine |
---|---|---|---|---|---|
1 | 1 | 1 | 643µs | 643µs | LoadYAML (xsub) | YAML::Syck::
3 | 1 | 1 | 395µs | 395µs | DumpYAML (xsub) | YAML::Syck::
1 | 1 | 1 | 48µs | 133µs | BEGIN@36 | YAML::Syck::
3 | 1 | 1 | 41µs | 436µs | Dump | YAML::Syck::
1 | 1 | 1 | 34µs | 305µs | BEGIN@15 | YAML::Syck::
1 | 1 | 1 | 31µs | 31µs | BEGIN@12 | YAML::Syck::
1 | 1 | 1 | 22µs | 29µs | BEGIN@4 | YAML::Syck::
1 | 1 | 1 | 18µs | 661µs | Load | YAML::Syck::
1 | 1 | 1 | 15µs | 59µs | BEGIN@13 | YAML::Syck::
1 | 1 | 1 | 14µs | 231µs | BEGIN@5 | YAML::Syck::
0 | 0 | 0 | 0s | 0s | DumpFile | YAML::Syck::
0 | 0 | 0 | 0s | 0s | LoadFile | YAML::Syck::
0 | 0 | 0 | 0s | 0s | __ANON__[:37] | YAML::Syck::
0 | 0 | 0 | 0s | 0s | __ANON__[:38] | YAML::Syck::
0 | 0 | 0 | 0s | 0s | __ANON__[:39] | YAML::Syck::
0 | 0 | 0 | 0s | 0s | __ANON__[:40] | YAML::Syck::
0 | 0 | 0 | 0s | 0s | __ANON__[:41] | YAML::Syck::
0 | 0 | 0 | 0s | 0s | __ANON__[:42] | YAML::Syck::
0 | 0 | 0 | 0s | 0s | __ANON__[:43] | YAML::Syck::
0 | 0 | 0 | 0s | 0s | __ANON__[:44] | YAML::Syck::
0 | 0 | 0 | 0s | 0s | __ANON__[:45] | YAML::Syck::
0 | 0 | 0 | 0s | 0s | __ANON__[:46] | YAML::Syck::
0 | 0 | 0 | 0s | 0s | __ANON__[:47] | YAML::Syck::
0 | 0 | 0 | 0s | 0s | __ANON__[:48] | YAML::Syck::
0 | 0 | 0 | 0s | 0s | __ANON__[:49] | YAML::Syck::
0 | 0 | 0 | 0s | 0s | __ANON__[:50] | YAML::Syck::
0 | 0 | 0 | 0s | 0s | __ANON__[:51] | YAML::Syck::
0 | 0 | 0 | 0s | 0s | __ANON__[:52] | YAML::Syck::
0 | 0 | 0 | 0s | 0s | __qr_helper | YAML::Syck::
0 | 0 | 0 | 0s | 0s | _is_openhandle | YAML::Syck::
Line | State ments |
Time on line |
Calls | Time in subs |
Code |
---|---|---|---|---|---|
1 | package YAML::Syck; | ||||
2 | # See documentation after the __END__ mark. | ||||
3 | |||||
4 | 3 | 105µs | 2 | 36µs | # spent 29µs (22+7) within YAML::Syck::BEGIN@4 which was called:
# once (22µs+7µs) by Date::Manip::Lang::english::BEGIN@24 at line 4 # spent 29µs making 1 call to YAML::Syck::BEGIN@4
# spent 7µs making 1 call to strict::import |
5 | 1 | 11µs | 1 | 217µs | # spent 231µs (14+217) within YAML::Syck::BEGIN@5 which was called:
# once (14µs+217µs) by Date::Manip::Lang::english::BEGIN@24 at line 11 # spent 217µs making 1 call to vars::import |
6 | @ISA @EXPORT $VERSION | ||||
7 | $Headless $SortKeys $SingleQuote | ||||
8 | $ImplicitBinary $ImplicitTyping $ImplicitUnicode | ||||
9 | $UseCode $LoadCode $DumpCode | ||||
10 | $DeparseObject $LoadBlessed | ||||
11 | 2 | 27µs | 1 | 231µs | ); # spent 231µs making 1 call to YAML::Syck::BEGIN@5 |
12 | 3 | 50µs | 1 | 31µs | # spent 31µs within YAML::Syck::BEGIN@12 which was called:
# once (31µs+0s) by Date::Manip::Lang::english::BEGIN@24 at line 12 # spent 31µs making 1 call to YAML::Syck::BEGIN@12 |
13 | 3 | 135µs | 2 | 103µs | # spent 59µs (15+44) within YAML::Syck::BEGIN@13 which was called:
# once (15µs+44µs) by Date::Manip::Lang::english::BEGIN@24 at line 13 # spent 59µs making 1 call to YAML::Syck::BEGIN@13
# spent 44µs making 1 call to Exporter::import |
14 | |||||
15 | # spent 305µs (34+270) within YAML::Syck::BEGIN@15 which was called:
# once (34µs+270µs) by Date::Manip::Lang::english::BEGIN@24 at line 34 | ||||
16 | 1 | 600ns | $VERSION = '1.12'; | ||
17 | 1 | 1µs | @EXPORT = qw( Dump Load DumpFile LoadFile ); | ||
18 | 1 | 12µs | @ISA = qw( Exporter ); | ||
19 | |||||
20 | 1 | 300ns | $SortKeys = 1; | ||
21 | 1 | 200ns | $LoadBlessed = 1; | ||
22 | |||||
23 | 1 | 300ns | local $@; | ||
24 | eval { | ||||
25 | 1 | 1µs | require XSLoader; | ||
26 | 1 | 282µs | 1 | 270µs | XSLoader::load(__PACKAGE__, $VERSION); # spent 270µs making 1 call to XSLoader::load |
27 | 1 | 1µs | 1; | ||
28 | 1 | 6µs | } or do { | ||
29 | require DynaLoader; | ||||
30 | push @ISA, 'DynaLoader'; | ||||
31 | __PACKAGE__->bootstrap($VERSION); | ||||
32 | }; | ||||
33 | |||||
34 | 1 | 354µs | 1 | 305µs | } # spent 305µs making 1 call to YAML::Syck::BEGIN@15 |
35 | |||||
36 | # spent 133µs (48+85) within YAML::Syck::BEGIN@36 which was called:
# once (48µs+85µs) by Date::Manip::Lang::english::BEGIN@24 at line 53 | ||||
37 | '' => sub { qr{$_[0]} }, | ||||
38 | x => sub { qr{$_[0]}x }, | ||||
39 | i => sub { qr{$_[0]}i }, | ||||
40 | s => sub { qr{$_[0]}s }, | ||||
41 | m => sub { qr{$_[0]}m }, | ||||
42 | ix => sub { qr{$_[0]}ix }, | ||||
43 | sx => sub { qr{$_[0]}sx }, | ||||
44 | mx => sub { qr{$_[0]}mx }, | ||||
45 | si => sub { qr{$_[0]}si }, | ||||
46 | mi => sub { qr{$_[0]}mi }, | ||||
47 | ms => sub { qr{$_[0]}sm }, | ||||
48 | six => sub { qr{$_[0]}six }, | ||||
49 | mix => sub { qr{$_[0]}mix }, | ||||
50 | msx => sub { qr{$_[0]}msx }, | ||||
51 | msi => sub { qr{$_[0]}msi }, | ||||
52 | msix => sub { qr{$_[0]}msix }, | ||||
53 | 3 | 587µs | 2 | 218µs | }; # spent 133µs making 1 call to YAML::Syck::BEGIN@36
# spent 85µs making 1 call to constant::import |
54 | |||||
55 | sub __qr_helper { | ||||
56 | if ($_[0] =~ /\A \(\? ([ixsm]*) (?:- (?:[ixsm]*))? : (.*) \) \z/x) { | ||||
57 | my $sub = QR_MAP()->{$1} || QR_MAP()->{''}; | ||||
58 | &$sub($2); | ||||
59 | } | ||||
60 | else { | ||||
61 | qr/$_[0]/; | ||||
62 | } | ||||
63 | } | ||||
64 | |||||
65 | # spent 436µs (41+395) within YAML::Syck::Dump which was called 3 times, avg 145µs/call:
# 3 times (41µs+395µs) by CGI::Session::Serialize::yaml::freeze at line 18 of CGI/Session/Serialize/yaml.pm, avg 145µs/call | ||||
66 | 3 | 438µs | 3 | 395µs | $#_ ? join('', map { YAML::Syck::DumpYAML($_) } @_) # spent 395µs making 3 calls to YAML::Syck::DumpYAML, avg 132µs/call |
67 | : YAML::Syck::DumpYAML($_[0]); | ||||
68 | } | ||||
69 | |||||
70 | # spent 661µs (18+643) within YAML::Syck::Load which was called:
# once (18µs+643µs) by Date::Manip::Base::_language at line 35 of Date/Manip/Lang/english.pm | ||||
71 | 1 | 9µs | if (wantarray) { | ||
72 | my ($rv) = YAML::Syck::LoadYAML($_[0]); | ||||
73 | @{$rv}; | ||||
74 | } | ||||
75 | else { | ||||
76 | 1 | 657µs | 1 | 643µs | YAML::Syck::LoadYAML($_[0]); # spent 643µs making 1 call to YAML::Syck::LoadYAML |
77 | } | ||||
78 | } | ||||
79 | |||||
80 | # NOTE. The code below (_is_openhandle) avoids to require/load | ||||
81 | # Scalar::Util unless it is given a ref or glob | ||||
82 | # as an argument. That is purposeful, so to avoid | ||||
83 | # the need for this dependency unless strictly necessary. | ||||
84 | # If that was not the case, Scalar::Util::openhandle could | ||||
85 | # be used directly. | ||||
86 | |||||
87 | sub _is_openhandle { | ||||
88 | my $h = shift; | ||||
89 | if ( ref($h) || ref(\$h) eq 'GLOB' ) { | ||||
90 | require Scalar::Util; | ||||
91 | return Scalar::Util::openhandle($h); | ||||
92 | } else { | ||||
93 | return undef; | ||||
94 | } | ||||
95 | } | ||||
96 | |||||
97 | sub DumpFile { | ||||
98 | my $file = shift; | ||||
99 | if ( _is_openhandle($file) ) { | ||||
100 | if ($#_) { | ||||
101 | print {$file} YAML::Syck::DumpYAML($_) for @_; | ||||
102 | } | ||||
103 | else { | ||||
104 | print {$file} YAML::Syck::DumpYAML($_[0]); | ||||
105 | } | ||||
106 | } | ||||
107 | else { | ||||
108 | open(my $fh, '>', $file) or die "Cannot write to $file: $!"; | ||||
109 | if ($#_) { | ||||
110 | print {$fh} YAML::Syck::DumpYAML($_) for @_; | ||||
111 | } | ||||
112 | else { | ||||
113 | print {$fh} YAML::Syck::DumpYAML($_[0]); | ||||
114 | } | ||||
115 | close $fh; | ||||
116 | } | ||||
117 | } | ||||
118 | |||||
119 | sub LoadFile { | ||||
120 | my $file = shift; | ||||
121 | if ( _is_openhandle($file) ) { | ||||
122 | if( -z $file ) { | ||||
123 | die("Cannot load an empty file"); | ||||
124 | }; | ||||
125 | Load(do { local $/; <$file> }); | ||||
126 | } | ||||
127 | else { | ||||
128 | if(!-e $file || -z $file) { | ||||
129 | die("'$file' is empty or non-existant"); | ||||
130 | } | ||||
131 | open(my $fh, '<', $file) or die "Cannot read from $file: $!"; | ||||
132 | Load(do { local $/; <$fh> }); | ||||
133 | } | ||||
134 | } | ||||
135 | |||||
136 | 1 | 4µs | 1; | ||
137 | |||||
138 | __END__ | ||||
# spent 395µs within YAML::Syck::DumpYAML which was called 3 times, avg 132µs/call:
# 3 times (395µs+0s) by YAML::Syck::Dump at line 66, avg 132µs/call | |||||
# spent 643µs within YAML::Syck::LoadYAML which was called:
# once (643µs+0s) by YAML::Syck::Load at line 76 |