Filename | /usr/lib/perl5/YAML/Syck.pm |
Statements | Executed 31 statements in 2.57ms |
Calls | P | F | Exclusive Time |
Inclusive Time |
Subroutine |
---|---|---|---|---|---|
1 | 1 | 1 | 703µs | 703µs | LoadYAML (xsub) | YAML::Syck::
3 | 1 | 1 | 307µs | 307µs | DumpYAML (xsub) | YAML::Syck::
1 | 1 | 1 | 53µs | 113µs | BEGIN@36 | YAML::Syck::
3 | 1 | 1 | 43µs | 350µs | Dump | YAML::Syck::
1 | 1 | 1 | 33µs | 269µs | BEGIN@15 | YAML::Syck::
1 | 1 | 1 | 23µs | 30µs | BEGIN@4 | YAML::Syck::
1 | 1 | 1 | 20µs | 20µs | BEGIN@12 | YAML::Syck::
1 | 1 | 1 | 17µs | 58µs | BEGIN@13 | YAML::Syck::
1 | 1 | 1 | 14µs | 209µs | BEGIN@5 | YAML::Syck::
1 | 1 | 1 | 14µs | 716µs | Load | 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 | 68µs | 2 | 36µs | # spent 30µs (23+7) within YAML::Syck::BEGIN@4 which was called:
# once (23µs+7µs) by Date::Manip::Lang::english::BEGIN@24 at line 4 # spent 30µs making 1 call to YAML::Syck::BEGIN@4
# spent 7µs making 1 call to strict::import |
5 | 1 | 194µs | # spent 209µs (14+194) within YAML::Syck::BEGIN@5 which was called:
# once (14µs+194µs) by Date::Manip::Lang::english::BEGIN@24 at line 11 # spent 194µ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 | 3 | 38µs | 1 | 209µs | ); # spent 209µs making 1 call to YAML::Syck::BEGIN@5 |
12 | 3 | 38µs | 1 | 20µs | # spent 20µs within YAML::Syck::BEGIN@12 which was called:
# once (20µs+0s) by Date::Manip::Lang::english::BEGIN@24 at line 12 # spent 20µs making 1 call to YAML::Syck::BEGIN@12 |
13 | 3 | 134µs | 2 | 99µs | # spent 58µs (17+41) within YAML::Syck::BEGIN@13 which was called:
# once (17µs+41µs) by Date::Manip::Lang::english::BEGIN@24 at line 13 # spent 58µs making 1 call to YAML::Syck::BEGIN@13
# spent 41µs making 1 call to Exporter::import |
14 | |||||
15 | # spent 269µs (33+236) within YAML::Syck::BEGIN@15 which was called:
# once (33µs+236µs) by Date::Manip::Lang::english::BEGIN@24 at line 34 | ||||
16 | 7 | 19µs | $VERSION = '1.12'; | ||
17 | @EXPORT = qw( Dump Load DumpFile LoadFile ); | ||||
18 | @ISA = qw( Exporter ); | ||||
19 | |||||
20 | $SortKeys = 1; | ||||
21 | $LoadBlessed = 1; | ||||
22 | |||||
23 | local $@; | ||||
24 | eval { | ||||
25 | require XSLoader; | ||||
26 | 1 | 236µs | XSLoader::load(__PACKAGE__, $VERSION); # spent 236µs making 1 call to XSLoader::load | ||
27 | 1; | ||||
28 | 3 | 250µs | } or do { | ||
29 | require DynaLoader; | ||||
30 | push @ISA, 'DynaLoader'; | ||||
31 | __PACKAGE__->bootstrap($VERSION); | ||||
32 | }; | ||||
33 | |||||
34 | 1 | 378µs | 1 | 269µs | } # spent 269µs making 1 call to YAML::Syck::BEGIN@15 |
35 | |||||
36 | # spent 113µs (53+60) within YAML::Syck::BEGIN@36 which was called:
# once (53µs+60µ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 | 572µs | 2 | 173µs | }; # spent 113µs making 1 call to YAML::Syck::BEGIN@36
# spent 60µ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 350µs (43+307) within YAML::Syck::Dump which was called 3 times, avg 117µs/call:
# 3 times (43µs+307µs) by CGI::Session::Serialize::yaml::freeze at line 18 of CGI/Session/Serialize/yaml.pm, avg 117µs/call | ||||
66 | 3 | 353µs | 3 | 307µs | $#_ ? join('', map { YAML::Syck::DumpYAML($_) } @_) # spent 307µs making 3 calls to YAML::Syck::DumpYAML, avg 102µs/call |
67 | : YAML::Syck::DumpYAML($_[0]); | ||||
68 | } | ||||
69 | |||||
70 | # spent 716µs (14+703) within YAML::Syck::Load which was called:
# once (14µs+703µs) by Date::Manip::Base::_language at line 35 of Date/Manip/Lang/english.pm | ||||
71 | 2 | 718µs | if (wantarray) { | ||
72 | my ($rv) = YAML::Syck::LoadYAML($_[0]); | ||||
73 | @{$rv}; | ||||
74 | } | ||||
75 | else { | ||||
76 | 1 | 703µs | YAML::Syck::LoadYAML($_[0]); # spent 703µ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 307µs within YAML::Syck::DumpYAML which was called 3 times, avg 102µs/call:
# 3 times (307µs+0s) by YAML::Syck::Dump at line 66, avg 102µs/call | |||||
# spent 703µs within YAML::Syck::LoadYAML which was called:
# once (703µs+0s) by YAML::Syck::Load at line 76 |