← Index
NYTProf Performance Profile   « line view »
For bin/benchmark-perlformance
  Run on Fri Apr 17 15:31:48 2015
Reported on Fri Apr 17 15:32:02 2015

Filename/home/ss5/perl5/perlbrew/perls/tapper-perl/lib/site_perl/5.16.3/Data/DPath/Path.pm
StatementsExecuted 426 statements in 2.16ms
Subroutines
Calls P F Exclusive
Time
Inclusive
Time
Subroutine
1113.74ms8.17msData::DPath::Path::::BEGIN@17Data::DPath::Path::BEGIN@17
1113.04ms3.45msData::DPath::Path::::BEGIN@13Data::DPath::Path::BEGIN@13
611574µs2.42msData::DPath::Path::::_build__stepsData::DPath::Path::_build__steps
111425µs2.68msData::DPath::Path::::BEGIN@14Data::DPath::Path::BEGIN@14
1721119µs132µsData::DPath::Path::::unescapeData::DPath::Path::unescape
632102µs2.52msData::DPath::Path::::newData::DPath::Path::new
171197µs121µsData::DPath::Path::::quotedData::DPath::Path::quoted
333167µs67µsData::DPath::Path::::CORE:matchData::DPath::Path::CORE:match (opcode)
61161µs90µsData::DPath::Path::::unquoteData::DPath::Path::unquote
21159µs640µsData::DPath::Path::::matchData::DPath::Path::match
403128µs28µsData::DPath::Path::::CORE:substData::DPath::Path::CORE:subst (opcode)
121113µs13µsData::DPath::Path::::CORE:substcontData::DPath::Path::CORE:substcont (opcode)
11112µs115µsData::DPath::Path::::BEGIN@27Data::DPath::Path::BEGIN@27
11111µs136µsData::DPath::Path::::BEGIN@20Data::DPath::Path::BEGIN@20
11110µs23µsData::DPath::Path::::BEGIN@121Data::DPath::Path::BEGIN@121
1118µs18µsData::DPath::Path::::BEGIN@10Data::DPath::Path::BEGIN@10
1117µs31.3msData::DPath::Path::::BEGIN@16Data::DPath::Path::BEGIN@16
1117µs10µsData::DPath::Path::::BEGIN@11Data::DPath::Path::BEGIN@11
1116µs381µsData::DPath::Path::::BEGIN@15Data::DPath::Path::BEGIN@15
1116µs6µsData::DPath::Path::::BEGIN@2Data::DPath::Path::BEGIN@2
2225µs5µsData::DPath::Path::::_stepsData::DPath::Path::_steps (xsub)
1112µs2µsData::DPath::Path::::pathData::DPath::Path::path (xsub)
1111µs1µsData::DPath::Path::::give_referencesData::DPath::Path::give_references (xsub)
0000s0sData::DPath::Path::::op_matchData::DPath::Path::op_match
Call graph for these subroutines as a Graphviz dot language file.
Line State
ments
Time
on line
Calls Time
in subs
Code
1package Data::DPath::Path;
2
# spent 6µs within Data::DPath::Path::BEGIN@2 which was called: # once (6µs+0s) by Data::DPath::BEGIN@20 at line 4
BEGIN {
314µs $Data::DPath::Path::AUTHORITY = 'cpan:SCHWIGON';
4119µs16µs}
# spent 6µs making 1 call to Data::DPath::Path::BEGIN@2
5{
62800ns $Data::DPath::Path::VERSION = '0.49';
7}
8# ABSTRACT: Abstraction for a DPath
9
10217µs227µs
# spent 18µs (8+9) within Data::DPath::Path::BEGIN@10 which was called: # once (8µs+9µs) by Data::DPath::BEGIN@20 at line 10
use strict;
# spent 18µs making 1 call to Data::DPath::Path::BEGIN@10 # spent 9µs making 1 call to strict::import
11218µs213µs
# spent 10µs (7+3) within Data::DPath::Path::BEGIN@11 which was called: # once (7µs+3µs) by Data::DPath::BEGIN@20 at line 11
use warnings;
# spent 10µs making 1 call to Data::DPath::Path::BEGIN@11 # spent 3µs making 1 call to warnings::import
12
13284µs23.48ms
# spent 3.45ms (3.04+416µs) within Data::DPath::Path::BEGIN@13 which was called: # once (3.04ms+416µs) by Data::DPath::BEGIN@20 at line 13
use Data::Dumper;
# spent 3.45ms making 1 call to Data::DPath::Path::BEGIN@13 # spent 25µs making 1 call to Exporter::import
14288µs24.89ms
# spent 2.68ms (425µs+2.26) within Data::DPath::Path::BEGIN@14 which was called: # once (425µs+2.26ms) by Data::DPath::BEGIN@20 at line 14
use aliased 'Data::DPath::Step';
# spent 2.68ms making 1 call to Data::DPath::Path::BEGIN@14 # spent 2.21ms making 1 call to aliased::import
15220µs2755µs
# spent 381µs (6+374) within Data::DPath::Path::BEGIN@15 which was called: # once (6µs+374µs) by Data::DPath::BEGIN@20 at line 15
use aliased 'Data::DPath::Point';
# spent 381µs making 1 call to Data::DPath::Path::BEGIN@15 # spent 374µs making 1 call to aliased::import
16232µs262.6ms
# spent 31.3ms (7µs+31.3) within Data::DPath::Path::BEGIN@16 which was called: # once (7µs+31.3ms) by Data::DPath::BEGIN@20 at line 16
use aliased 'Data::DPath::Context';
# spent 31.3ms making 1 call to Data::DPath::Path::BEGIN@16 # spent 31.3ms making 1 call to aliased::import
173125µs38.23ms
# spent 8.17ms (3.74+4.43) within Data::DPath::Path::BEGIN@17 which was called: # once (3.74ms+4.43ms) by Data::DPath::BEGIN@20 at line 17
use Text::Balanced 2.02 'extract_delimited', 'extract_codeblock';
# spent 8.17ms making 1 call to Data::DPath::Path::BEGIN@17 # spent 50µs making 1 call to Exporter::import # spent 11µs making 1 call to UNIVERSAL::VERSION
18
19use Class::XSAccessor
2018µs1125µs
# spent 136µs (11+125) within Data::DPath::Path::BEGIN@20 which was called: # once (11µs+125µs) by Data::DPath::BEGIN@20 at line 25
chained => 1,
# spent 125µs making 1 call to Class::XSAccessor::import
21 accessors => {
22 path => 'path',
23 _steps => '_steps',
24 give_references => 'give_references',
25131µs1136µs };
# spent 136µs making 1 call to Data::DPath::Path::BEGIN@20
26
27110µs1103µs
# spent 115µs (12+103) within Data::DPath::Path::BEGIN@27 which was called: # once (12µs+103µs) by Data::DPath::BEGIN@20 at line 35
use constant { ROOT => 'ROOT',
# spent 103µs making 1 call to constant::import
28 ANYWHERE => 'ANYWHERE',
29 KEY => 'KEY',
30 ANYSTEP => 'ANYSTEP',
31 NOSTEP => 'NOSTEP',
32 PARENT => 'PARENT',
33 ANCESTOR => 'ANCESTOR',
34 ANCESTOR_OR_SELF => 'ANCESTOR_OR_SELF',
351350µs1115µs };
# spent 115µs making 1 call to Data::DPath::Path::BEGIN@27
36
37
# spent 2.52ms (102µs+2.42) within Data::DPath::Path::new which was called 6 times, avg 420µs/call: # 3 times (23µs+458µs) by Data::DPath::Context::isearch at line 417 of Data/DPath/Context.pm, avg 160µs/call # 2 times (16µs+1.61ms) by Data::DPath::__ANON__[/home/ss5/perl5/perlbrew/perls/tapper-perl/lib/site_perl/5.16.3/Data/DPath.pm:27] at line 26 of Data/DPath.pm, avg 813µs/call # once (62µs+348µs) by Data::DPath::__ANON__[/home/ss5/perl5/perlbrew/perls/tapper-perl/lib/site_perl/5.16.3/Data/DPath.pm:47] at line 41 of Data/DPath.pm
sub new {
3864µs my $class = shift;
39662µs my $self = bless { @_ }, $class;
40615µs62.42ms $self->_build__steps;
# spent 2.42ms making 6 calls to Data::DPath::Path::_build__steps, avg 403µs/call
41626µs return $self;
42}
43
44
# spent 132µs (119+13) within Data::DPath::Path::unescape which was called 17 times, avg 8µs/call: # 11 times (82µs+9µs) by Data::DPath::Path::_build__steps at line 118, avg 8µs/call # 6 times (38µs+4µs) by Data::DPath::Path::_build__steps at line 86, avg 7µs/call
sub unescape {
45179µs my ($str) = @_;
46
47173µs return unless defined $str;
481750µs177µs $str =~ s/(?<!\\)\\(["'])/$1/g; # '"$
# spent 7µs making 17 calls to Data::DPath::Path::CORE:subst, avg 435ns/call
491738µs175µs $str =~ s/\\{2}/\\/g;
# spent 5µs making 17 calls to Data::DPath::Path::CORE:subst, avg 306ns/call
501750µs return $str;
51}
52
53
# spent 90µs (61+29) within Data::DPath::Path::unquote which was called 6 times, avg 15µs/call: # 6 times (61µs+29µs) by Data::DPath::Path::_build__steps at line 86, avg 15µs/call
sub unquote {
5463µs my ($str) = @_;
55675µs1829µs $str =~ s/^"(.*)"$/$1/g;
# spent 16µs making 6 calls to Data::DPath::Path::CORE:subst, avg 3µs/call # spent 13µs making 12 calls to Data::DPath::Path::CORE:substcont, avg 1µs/call
56620µs return $str;
57}
58
5917144µs1724µs
# spent 121µs (97+24) within Data::DPath::Path::quoted which was called 17 times, avg 7µs/call: # 17 times (97µs+24µs) by Data::DPath::Path::_build__steps at line 83, avg 7µs/call
sub quoted { shift =~ m,^/["'],; } # "
# spent 24µs making 17 calls to Data::DPath::Path::CORE:match, avg 1µs/call
60
61139µseval 'use overload "~~" => \&op_match' if $] >= 5.010;
# spent 12µs executing statements in string eval
# includes 10µs spent executing 1 call to 1 sub defined therein.
62
63sub op_match {
64 my ($self, $data, $rhs) = @_;
65
66 return [ $self->match( $data ) ];
67}
68
69# essentially the Path parser
70
# spent 2.42ms (574µs+1.84) within Data::DPath::Path::_build__steps which was called 6 times, avg 403µs/call: # 6 times (574µs+1.84ms) by Data::DPath::Path::new at line 40, avg 403µs/call
sub _build__steps {
7164µs my ($self) = @_;
72
73621µs12µs my $remaining_path = $self->path;
# spent 2µs making 1 call to Data::DPath::Path::path
746800ns my $extracted;
7562µs my @steps;
76
77666µs313µs push @steps, Step->new->part('')->kind(ROOT);
# spent 9µs making 1 call to Data::DPath::Step::new # spent 2µs making 1 call to Data::DPath::Step::kind # spent 1µs making 1 call to Data::DPath::Step::part
78
7964µs while ($remaining_path) {
80172µs my $plain_part;
81172µs my $filter;
82172µs my $kind;
831731µs17121µs if ( quoted($remaining_path) ) {
# spent 121µs making 17 calls to Data::DPath::Path::quoted, avg 7µs/call
84620µs6347µs ($plain_part, $remaining_path) = extract_delimited($remaining_path, q/'"/, "/"); # '
# spent 347µs making 6 calls to Text::Balanced::extract_delimited, avg 58µs/call
85622µs6377µs ($filter, $remaining_path) = extract_codeblock($remaining_path, "[]");
# spent 377µs making 6 calls to Text::Balanced::extract_codeblock, avg 63µs/call
86619µs12131µs $plain_part = unescape unquote $plain_part;
# spent 90µs making 6 calls to Data::DPath::Path::unquote, avg 15µs/call # spent 41µs making 6 calls to Data::DPath::Path::unescape, avg 7µs/call
8763µs $kind = KEY; # quoted is always a key
88 }
89 else
90 {
91114µs my $filter_already_extracted = 0;
921138µs11705µs ($extracted, $remaining_path) = extract_delimited($remaining_path,'/');
# spent 705µs making 11 calls to Text::Balanced::extract_delimited, avg 64µs/call
93
941110µs if (not $extracted) {
95 ($extracted, $remaining_path) = ($remaining_path, undef); # END OF PATH
96 } else {
97
98 # work around to recognize slashes in filter expressions and handle them:
99 #
100 # - 1) see if key unexpectedly contains opening "[" but no closing "]"
101 # - 2) use the part before "["
102 # - 3) unshift the rest to remaining
103 # - 4) extract_codeblock() explicitely
104520µs54µs if ($extracted =~ /(.*)((?<!\\)\[.*)/ and $extracted !~ m|\]/\s*$|) {
# spent 4µs making 5 calls to Data::DPath::Path::CORE:match, avg 760ns/call
105 $remaining_path = $2 . $remaining_path;
106 ( $plain_part = $1 ) =~ s|^/||;
107 ($filter, $remaining_path) = extract_codeblock($remaining_path, "[]");
108 $filter_already_extracted = 1;
109 } else {
11058µs $remaining_path = (chop $extracted) . $remaining_path;
111 }
112 }
113
1141181µs1139µs ($plain_part, $filter) = $extracted =~ m,^/ # leading /
# spent 39µs making 11 calls to Data::DPath::Path::CORE:match, avg 4µs/call
115 (.*?) # path part
116 (\[.*\])?$ # optional filter
117 ,xg unless $filter_already_extracted;
1181124µs1191µs $plain_part = unescape $plain_part;
# spent 91µs making 11 calls to Data::DPath::Path::unescape, avg 8µs/call
119 }
120
1212171µs236µs
# spent 23µs (10+13) within Data::DPath::Path::BEGIN@121 which was called: # once (10µs+13µs) by Data::DPath::BEGIN@20 at line 121
no warnings 'uninitialized';
# spent 23µs making 1 call to Data::DPath::Path::BEGIN@121 # spent 13µs making 1 call to warnings::unimport
1221717µs if ($plain_part eq '') { $kind ||= ANYWHERE }
123 elsif ($plain_part eq '*') { $kind ||= ANYSTEP }
124 elsif ($plain_part eq '.') { $kind ||= NOSTEP }
125 elsif ($plain_part eq '..') { $kind ||= PARENT }
126 elsif ($plain_part eq '::ancestor') { $kind ||= ANCESTOR }
127 elsif ($plain_part eq '::ancestor-or-self') { $kind ||= ANCESTOR_OR_SELF }
128114µs else { $kind ||= KEY }
129
13017120µs48µs push @steps, Step->new->part($plain_part)->kind($kind)->filter($filter);
# spent 3µs making 1 call to Data::DPath::Step::new # spent 2µs making 1 call to Data::DPath::Step::kind # spent 1µs making 1 call to Data::DPath::Step::part # spent 1µs making 1 call to Data::DPath::Step::filter
131 }
132613µs12µs pop @steps if $steps[-1]->kind eq ANYWHERE; # ignore final '/'
# spent 2µs making 1 call to Data::DPath::Step::kind
133638µs14µs $self->_steps( \@steps );
# spent 4µs making 1 call to Data::DPath::Path::_steps
134}
135
136
# spent 640µs (59+581) within Data::DPath::Path::match which was called 2 times, avg 320µs/call: # 2 times (59µs+581µs) by Benchmark::Perl::Formance::print_outstyle_summary at line 725 of lib/Benchmark/Perl/Formance.pm, avg 320µs/call
sub match {
13722µs my ($self, $data) = @_;
138
139252µs69µs my $context = Context
# spent 2µs making 1 call to Data::DPath::Context::new # spent 2µs making 1 call to Data::DPath::Point::new # spent 1µs making 1 call to Data::DPath::Path::give_references # spent 1µs making 1 call to Data::DPath::Context::current_points # spent 1µs making 1 call to Data::DPath::Point::ref # spent 700ns making 1 call to Data::DPath::Context::give_references
140 ->new
141 ->current_points([ Point->new->ref(\$data) ])
142 ->give_references($self->give_references);
143212µs2572µs return $context->match($self);
# spent 572µs making 2 calls to Data::DPath::Context::match, avg 286µs/call
144}
145
14612µs1;
147
148__END__
 
# spent 67µs within Data::DPath::Path::CORE:match which was called 33 times, avg 2µs/call: # 17 times (24µs+0s) by Data::DPath::Path::quoted at line 59, avg 1µs/call # 11 times (39µs+0s) by Data::DPath::Path::_build__steps at line 114, avg 4µs/call # 5 times (4µs+0s) by Data::DPath::Path::_build__steps at line 104, avg 760ns/call
sub Data::DPath::Path::CORE:match; # opcode
# spent 28µs within Data::DPath::Path::CORE:subst which was called 40 times, avg 705ns/call: # 17 times (7µs+0s) by Data::DPath::Path::unescape at line 48, avg 435ns/call # 17 times (5µs+0s) by Data::DPath::Path::unescape at line 49, avg 306ns/call # 6 times (16µs+0s) by Data::DPath::Path::unquote at line 55, avg 3µs/call
sub Data::DPath::Path::CORE:subst; # opcode
# spent 13µs within Data::DPath::Path::CORE:substcont which was called 12 times, avg 1µs/call: # 12 times (13µs+0s) by Data::DPath::Path::unquote at line 55, avg 1µs/call
sub Data::DPath::Path::CORE:substcont; # opcode
# spent 5µs within Data::DPath::Path::_steps which was called 2 times, avg 2µs/call: # once (4µs+0s) by Data::DPath::Path::_build__steps at line 133 # once (900ns+0s) by Data::DPath::Context::_search at line 428 of Data/DPath/Context.pm
sub Data::DPath::Path::_steps; # xsub
# spent 1µs within Data::DPath::Path::give_references which was called: # once (1µs+0s) by Data::DPath::Path::match at line 139
sub Data::DPath::Path::give_references; # xsub
# spent 2µs within Data::DPath::Path::path which was called: # once (2µs+0s) by Data::DPath::Path::_build__steps at line 73
sub Data::DPath::Path::path; # xsub