| Filename | /home/ss5/perl5/perlbrew/perls/perl-5.14.1/lib/site_perl/5.14.1/x86_64-linux-thread-multi/YAML/XS.pm |
| Statements | Executed 20 statements in 6.39ms |
| Calls | P | F | Exclusive Time |
Inclusive Time |
Subroutine |
|---|---|---|---|---|---|
| 1 | 1 | 1 | 124ms | 137ms | YAML::XS::BEGIN@56 |
| 1 | 1 | 1 | 894µs | 2.36ms | YAML::XS::BEGIN@19 |
| 1 | 1 | 1 | 162µs | 373µs | YAML::XS::BEGIN@101 |
| 1 | 1 | 1 | 93µs | 93µs | YAML::Any::BEGIN@1 |
| 1 | 1 | 1 | 35µs | 378µs | YAML::XS::BEGIN@6 |
| 1 | 1 | 1 | 30µs | 43µs | YAML::Any::BEGIN@2 |
| 0 | 0 | 0 | 0s | 0s | YAML::XS::DumpFile |
| 0 | 0 | 0 | 0s | 0s | YAML::XS::LoadFile |
| 0 | 0 | 0 | 0s | 0s | YAML::XS::__ANON__[:102] |
| 0 | 0 | 0 | 0s | 0s | YAML::XS::__ANON__[:103] |
| 0 | 0 | 0 | 0s | 0s | YAML::XS::__ANON__[:104] |
| 0 | 0 | 0 | 0s | 0s | YAML::XS::__ANON__[:105] |
| 0 | 0 | 0 | 0s | 0s | YAML::XS::__ANON__[:106] |
| 0 | 0 | 0 | 0s | 0s | YAML::XS::__ANON__[:107] |
| 0 | 0 | 0 | 0s | 0s | YAML::XS::__ANON__[:108] |
| 0 | 0 | 0 | 0s | 0s | YAML::XS::__ANON__[:109] |
| 0 | 0 | 0 | 0s | 0s | YAML::XS::__ANON__[:110] |
| 0 | 0 | 0 | 0s | 0s | YAML::XS::__ANON__[:111] |
| 0 | 0 | 0 | 0s | 0s | YAML::XS::__ANON__[:112] |
| 0 | 0 | 0 | 0s | 0s | YAML::XS::__ANON__[:113] |
| 0 | 0 | 0 | 0s | 0s | YAML::XS::__ANON__[:114] |
| 0 | 0 | 0 | 0s | 0s | YAML::XS::__ANON__[:115] |
| 0 | 0 | 0 | 0s | 0s | YAML::XS::__ANON__[:116] |
| 0 | 0 | 0 | 0s | 0s | YAML::XS::__ANON__[:117] |
| 0 | 0 | 0 | 0s | 0s | YAML::XS::__ANON__[:75] |
| 0 | 0 | 0 | 0s | 0s | YAML::XS::__ANON__[:99] |
| 0 | 0 | 0 | 0s | 0s | YAML::XS::__qr_loader |
| Line | State ments |
Time on line |
Calls | Time in subs |
Code |
|---|---|---|---|---|---|
| 1 | 2 | 192µs | 1 | 93µs | # spent 93µs within YAML::Any::BEGIN@1 which was called:
# once (93µs+0s) by YAML::Any::implementation at line 1 # spent 93µs making 1 call to YAML::Any::BEGIN@1 |
| 2 | 2 | 158µs | 2 | 57µ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 # spent 43µs making 1 call to YAML::Any::BEGIN@2
# spent 14µs making 1 call to strict::import |
| 3 | |||||
| 4 | package YAML::XS; | ||||
| 5 | 1 | 4µs | $YAML::XS::VERSION = '0.38'; | ||
| 6 | 2 | 313µs | 2 | 721µ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 # spent 378µs making 1 call to YAML::XS::BEGIN@6
# spent 343µs making 1 call to base::import |
| 7 | |||||
| 8 | 1 | 6µs | @YAML::XS::EXPORT = qw(Load Dump); | ||
| 9 | 1 | 3µs | @YAML::XS::EXPORT_OK = qw(LoadFile DumpFile); | ||
| 10 | 1 | 10µ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 | |||||
| 17 | 1 | 1µs | $YAML::XS::QuoteNumericStrings = 1; | ||
| 18 | |||||
| 19 | 2 | 1.29ms | 2 | 2.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 # spent 2.36ms making 1 call to YAML::XS::BEGIN@19
# spent 196µs making 1 call to Exporter::import |
| 20 | |||||
| 21 | sub 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 | |||||
| 39 | sub 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. | ||||
| 56 | 2 | 3.36ms | 1 | 137ms | # spent 137ms (124+12.5) within YAML::XS::BEGIN@56 which was called:
# once (124ms+12.5ms) by YAML::Any::implementation at line 56 # 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; | ||||
| 75 | 1 | 17µ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; | ||||
| 99 | 1 | 14µ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 | ||||
| 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 }, | ||||
| 118 | 2 | 991µs | 2 | 584µs | }; # spent 373µs making 1 call to YAML::XS::BEGIN@101
# spent 211µs making 1 call to constant::import |
| 119 | |||||
| 120 | sub __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 | |||||
| 130 | 1 | 30µs | 1; | ||
| 131 | |||||
| 132 | =encoding utf8 | ||||
| 133 | |||||
| 134 | =head1 NAME | ||||
| 135 | |||||
| 136 | YAML::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 | |||||
| 147 | Kirill Siminov's C<libyaml> is arguably the best YAML implementation. | ||||
| 148 | The C library is written precisely to the YAML 1.1 specification. It was | ||||
| 149 | originally bound to Python and was later bound to Ruby. | ||||
| 150 | |||||
| 151 | This module is a Perl XS binding to libyaml which offers Perl the best YAML | ||||
| 152 | support to date. | ||||
| 153 | |||||
| 154 | This module exports the functions C<Dump>, C<Load>, C<DumpFile> and | ||||
| 155 | C<LoadFile>. These functions are intended to work exactly like C<YAML.pm>'s | ||||
| 156 | corresponding 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 | |||||
| 168 | If enabled supports deparsing and evaling of code blocks. | ||||
| 169 | |||||
| 170 | =item C<$YAML::XS::QuoteNumericStrings> | ||||
| 171 | |||||
| 172 | When true (the default) strings that look like numbers but have not been | ||||
| 173 | numified will be quoted when dumping. | ||||
| 174 | |||||
| 175 | This ensures leading that things like leading zeros and other formatting | ||||
| 176 | are preserved. | ||||
| 177 | |||||
| 178 | =back | ||||
| 179 | |||||
| 180 | =head1 USING YAML::XS WITH UNICODE | ||||
| 181 | |||||
| 182 | Handling unicode properly in Perl can be a pain. YAML::XS only deals | ||||
| 183 | with streams of utf8 octets. Just remember this: | ||||
| 184 | |||||
| 185 | $perl = Load($utf8_octets); | ||||
| 186 | $utf8_octets = Dump($perl); | ||||
| 187 | |||||
| 188 | There are many, many places where things can go wrong with unicode. | ||||
| 189 | If you are having problems, use Devel::Peek on all the possible | ||||
| 190 | data points. | ||||
| 191 | |||||
| 192 | =head1 SEE ALSO | ||||
| 193 | |||||
| 194 | * YAML.pm | ||||
| 195 | * YAML::Syck | ||||
| 196 | * YAML::Tiny | ||||
| 197 | |||||
| 198 | =head1 AUTHOR | ||||
| 199 | |||||
| 200 | Ingy döt Net <ingy@cpan.org> | ||||
| 201 | |||||
| 202 | =head1 COPYRIGHT | ||||
| 203 | |||||
| 204 | Copyright (c) 2007, 2008, 2010, 2011. Ingy döt Net. | ||||
| 205 | |||||
| 206 | This program is free software; you can redistribute it and/or modify it | ||||
| 207 | under the same terms as Perl itself. | ||||
| 208 | |||||
| 209 | See http://www.perl.com/perl/misc/Artistic.html | ||||
| 210 | |||||
| 211 | =cut |