← Index
NYTProf Performance Profile   « block view • line view • sub view »
For bin/dpath
  Run on Tue Jun 5 15:30:18 2012
Reported on Tue Jun 5 15:30:47 2012

Filename/home/ss5/perl5/perlbrew/perls/perl-5.14.1/lib/site_perl/5.14.1/x86_64-linux-thread-multi/YAML/XS.pm
StatementsExecuted 20 statements in 6.39ms
Subroutines
Calls P F Exclusive
Time
Inclusive
Time
Subroutine
111124ms137msYAML::XS::::BEGIN@56 YAML::XS::BEGIN@56
111894µs2.36msYAML::XS::::BEGIN@19 YAML::XS::BEGIN@19
111162µs373µsYAML::XS::::BEGIN@101 YAML::XS::BEGIN@101
11193µs93µsYAML::Any::::BEGIN@1YAML::Any::BEGIN@1
11135µs378µsYAML::XS::::BEGIN@6 YAML::XS::BEGIN@6
11130µs43µsYAML::Any::::BEGIN@2YAML::Any::BEGIN@2
0000s0sYAML::XS::::DumpFile YAML::XS::DumpFile
0000s0sYAML::XS::::LoadFile YAML::XS::LoadFile
0000s0sYAML::XS::::__ANON__[:102] YAML::XS::__ANON__[:102]
0000s0sYAML::XS::::__ANON__[:103] YAML::XS::__ANON__[:103]
0000s0sYAML::XS::::__ANON__[:104] YAML::XS::__ANON__[:104]
0000s0sYAML::XS::::__ANON__[:105] YAML::XS::__ANON__[:105]
0000s0sYAML::XS::::__ANON__[:106] YAML::XS::__ANON__[:106]
0000s0sYAML::XS::::__ANON__[:107] YAML::XS::__ANON__[:107]
0000s0sYAML::XS::::__ANON__[:108] YAML::XS::__ANON__[:108]
0000s0sYAML::XS::::__ANON__[:109] YAML::XS::__ANON__[:109]
0000s0sYAML::XS::::__ANON__[:110] YAML::XS::__ANON__[:110]
0000s0sYAML::XS::::__ANON__[:111] YAML::XS::__ANON__[:111]
0000s0sYAML::XS::::__ANON__[:112] YAML::XS::__ANON__[:112]
0000s0sYAML::XS::::__ANON__[:113] YAML::XS::__ANON__[:113]
0000s0sYAML::XS::::__ANON__[:114] YAML::XS::__ANON__[:114]
0000s0sYAML::XS::::__ANON__[:115] YAML::XS::__ANON__[:115]
0000s0sYAML::XS::::__ANON__[:116] YAML::XS::__ANON__[:116]
0000s0sYAML::XS::::__ANON__[:117] YAML::XS::__ANON__[:117]
0000s0sYAML::XS::::__ANON__[:75] YAML::XS::__ANON__[:75]
0000s0sYAML::XS::::__ANON__[:99] YAML::XS::__ANON__[:99]
0000s0sYAML::XS::::__qr_loader YAML::XS::__qr_loader
Call graph for these subroutines as a Graphviz dot language file.
Line State
ments
Time
on line
Calls Time
in subs
Code
12192µs193µs
# spent 93µs within YAML::Any::BEGIN@1 which was called: # once (93µs+0s) by YAML::Any::implementation at line 1
use 5.008001;
# spent 93µs making 1 call to YAML::Any::BEGIN@1
22158µs257µs
# spent 43µs (30+14) within YAML::Any::BEGIN@2 which was called: # once (30µs+14µs) by YAML::Any::implementation at line 2
use strict;
# spent 43µs making 1 call to YAML::Any::BEGIN@2 # spent 14µs making 1 call to strict::import
3
4package YAML::XS;
514µs$YAML::XS::VERSION = '0.38';
62313µs2721µs
# spent 378µs (35+343) within YAML::XS::BEGIN@6 which was called: # once (35µs+343µs) by YAML::Any::implementation at line 6
use base 'Exporter';
# spent 378µs making 1 call to YAML::XS::BEGIN@6 # spent 343µs making 1 call to base::import
7
816µs@YAML::XS::EXPORT = qw(Load Dump);
913µs@YAML::XS::EXPORT_OK = qw(LoadFile DumpFile);
10110µs%YAML::XS::EXPORT_TAGS = (
11 all => [qw(Dump Load LoadFile DumpFile)],
12);
13# $YAML::XS::UseCode = 0;
14# $YAML::XS::DumpCode = 0;
15# $YAML::XS::LoadCode = 0;
16
1711µs$YAML::XS::QuoteNumericStrings = 1;
18
1921.29ms22.56ms
# spent 2.36ms (894µs+1.47) within YAML::XS::BEGIN@19 which was called: # once (894µs+1.47ms) by YAML::Any::implementation at line 19
use YAML::XS::LibYAML qw(Load Dump);
# spent 2.36ms making 1 call to YAML::XS::BEGIN@19 # spent 196µs making 1 call to Exporter::import
20
21sub DumpFile {
22 my $OUT;
23 my $filename = shift;
24 if (ref $filename eq 'GLOB') {
25 $OUT = $filename;
26 }
27 else {
28 my $mode = '>';
29 if ($filename =~ /^\s*(>{1,2})\s*(.*)$/) {
30 ($mode, $filename) = ($1, $2);
31 }
32 open $OUT, $mode, $filename
33 or die "Can't open '$filename' for output:\n$!";
34 }
35 local $/ = "\n"; # reset special to "sane"
36 print $OUT YAML::XS::LibYAML::Dump(@_);
37}
38
39sub LoadFile {
40 my $IN;
41 my $filename = shift;
42 if (ref $filename eq 'GLOB') {
43 $IN = $filename;
44 }
45 else {
46 open $IN, $filename
47 or die "Can't open '$filename' for input:\n$!";
48 }
49 return YAML::XS::LibYAML::Load(do { local $/; local $_ = <$IN> });
50}
51
52# XXX Figure out how to lazily load this module.
53# So far I've tried using the C function:
54# load_module(PERL_LOADMOD_NOIMPORT, newSVpv("B::Deparse", 0), NULL);
55# But it didn't seem to work.
5623.36ms1137ms
# spent 137ms (124+12.5) within YAML::XS::BEGIN@56 which was called: # once (124ms+12.5ms) by YAML::Any::implementation at line 56
use B::Deparse;
# spent 137ms making 1 call to YAML::XS::BEGIN@56
57
58# XXX The following code should be moved from Perl to C.
59$YAML::XS::coderef2text = sub {
60 my $coderef = shift;
61 my $deparse = B::Deparse->new();
62 my $text;
63 eval {
64 local $^W = 0;
65 $text = $deparse->coderef2text($coderef);
66 };
67 if ($@) {
68 warn "YAML::XS failed to dump code ref:\n$@";
69 return;
70 }
71 $text =~ s[BEGIN \{\$\{\^WARNING_BITS\} = "UUUUUUUUUUUU\\001"\}]
72 [use warnings;]g;
73
74 return $text;
75117µs};
76
77$YAML::XS::glob2hash = sub {
78 my $hash = {};
79 for my $type (qw(PACKAGE NAME SCALAR ARRAY HASH CODE IO)) {
80 my $value = *{$_[0]}{$type};
81 $value = $$value if $type eq 'SCALAR';
82 if (defined $value) {
83 if ($type eq 'IO') {
84 my @stats = qw(device inode mode links uid gid rdev size
85 atime mtime ctime blksize blocks);
86 undef $value;
87 $value->{stat} = {};
88 map {$value->{stat}{shift @stats} = $_} stat(*{$_[0]});
89 $value->{fileno} = fileno(*{$_[0]});
90 {
91 local $^W;
92 $value->{tell} = tell(*{$_[0]});
93 }
94 }
95 $hash->{$type} = $value;
96 }
97 }
98 return $hash;
99114µs};
100
101
# spent 373µs (162+211) within YAML::XS::BEGIN@101 which was called: # once (162µs+211µs) by YAML::Any::implementation at line 118
use constant _QR_MAP => {
102 '' => sub { qr{$_[0]} },
103 x => sub { qr{$_[0]}x },
104 i => sub { qr{$_[0]}i },
105 s => sub { qr{$_[0]}s },
106 m => sub { qr{$_[0]}m },
107 ix => sub { qr{$_[0]}ix },
108 sx => sub { qr{$_[0]}sx },
109 mx => sub { qr{$_[0]}mx },
110 si => sub { qr{$_[0]}si },
111 mi => sub { qr{$_[0]}mi },
112 ms => sub { qr{$_[0]}sm },
113 six => sub { qr{$_[0]}six },
114 mix => sub { qr{$_[0]}mix },
115 msx => sub { qr{$_[0]}msx },
116 msi => sub { qr{$_[0]}msi },
117 msix => sub { qr{$_[0]}msix },
1182991µs2584µs};
# spent 373µs making 1 call to YAML::XS::BEGIN@101 # spent 211µs making 1 call to constant::import
119
120sub __qr_loader {
121 if ($_[0] =~ /\A \(\? ([ixsm]*) (?:- (?:[ixsm]*))? : (.*) \) \z/x) {
122 my $sub = _QR_MAP->{$1} || _QR_MAP->{''};
123 &$sub($2);
124 }
125 else {
126 qr/$_[0]/;
127 }
128}
129
130130µs1;
131
132=encoding utf8
133
134=head1 NAME
135
136YAML::XS - Perl YAML Serialization using XS and libyaml
137
138=head1 SYNOPSIS
139
140 use YAML::XS;
141
142 my $yaml = Dump [ 1..4 ];
143 my $array = Load $yaml;
144
145=head1 DESCRIPTION
146
147Kirill Siminov's C<libyaml> is arguably the best YAML implementation.
148The C library is written precisely to the YAML 1.1 specification. It was
149originally bound to Python and was later bound to Ruby.
150
151This module is a Perl XS binding to libyaml which offers Perl the best YAML
152support to date.
153
154This module exports the functions C<Dump>, C<Load>, C<DumpFile> and
155C<LoadFile>. These functions are intended to work exactly like C<YAML.pm>'s
156corresponding functions.
157
158=head1 CONFIGURATION
159
160=over 4
161
162=item C<$YAML::XS::UseCode>
163
164=item C<$YAML::XS::DumpCode>
165
166=item C<$YAML::XS::LoadCode>
167
168If enabled supports deparsing and evaling of code blocks.
169
170=item C<$YAML::XS::QuoteNumericStrings>
171
172When true (the default) strings that look like numbers but have not been
173numified will be quoted when dumping.
174
175This ensures leading that things like leading zeros and other formatting
176are preserved.
177
178=back
179
180=head1 USING YAML::XS WITH UNICODE
181
182Handling unicode properly in Perl can be a pain. YAML::XS only deals
183with streams of utf8 octets. Just remember this:
184
185 $perl = Load($utf8_octets);
186 $utf8_octets = Dump($perl);
187
188There are many, many places where things can go wrong with unicode.
189If you are having problems, use Devel::Peek on all the possible
190data points.
191
192=head1 SEE ALSO
193
194 * YAML.pm
195 * YAML::Syck
196 * YAML::Tiny
197
198=head1 AUTHOR
199
200Ingy döt Net <ingy@cpan.org>
201
202=head1 COPYRIGHT
203
204Copyright (c) 2007, 2008, 2010, 2011. Ingy döt Net.
205
206This program is free software; you can redistribute it and/or modify it
207under the same terms as Perl itself.
208
209See http://www.perl.com/perl/misc/Artistic.html
210
211=cut