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

Filename/home/ss5/perl5/perlbrew/perls/perl-5.14.1/lib/site_perl/5.14.1/x86_64-linux-thread-multi/Class/XSAccessor.pm
StatementsExecuted 277 statements in 6.81ms
Subroutines
Calls P F Exclusive
Time
Inclusive
Time
Subroutine
1111.70ms2.20msClass::XSAccessor::::BEGIN@6Class::XSAccessor::BEGIN@6
4441.09ms2.66msClass::XSAccessor::::importClass::XSAccessor::import
921431µs1.33msClass::XSAccessor::::_generate_methodClass::XSAccessor::_generate_method
711242µs242µsClass::XSAccessor::::newxs_accessorClass::XSAccessor::newxs_accessor (xsub)
2461241µs241µsClass::XSAccessor::::_make_hashClass::XSAccessor::_make_hash
11175µs75µsClass::XSAccessor::::BEGIN@2Class::XSAccessor::BEGIN@2
11137µs89µsClass::XSAccessor::::BEGIN@80Class::XSAccessor::BEGIN@80
91133µs33µsClass::XSAccessor::::CORE:matchClass::XSAccessor::CORE:match (opcode)
21128µs28µsClass::XSAccessor::::newxs_constructorClass::XSAccessor::newxs_constructor (xsub)
11128µs40µsClass::XSAccessor::::BEGIN@3Class::XSAccessor::BEGIN@3
11127µs132µsClass::XSAccessor::::BEGIN@5Class::XSAccessor::BEGIN@5
11127µs49µsClass::XSAccessor::::BEGIN@4Class::XSAccessor::BEGIN@4
11124µs24µsClass::XSAccessor::::BEGIN@7Class::XSAccessor::BEGIN@7
1118µs8µsClass::XSAccessor::::ENDClass::XSAccessor::END (xsub)
Call graph for these subroutines as a Graphviz dot language file.
Line State
ments
Time
on line
Calls Time
in subs
Code
1package Class::XSAccessor;
22177µs175µs
# spent 75µs within Class::XSAccessor::BEGIN@2 which was called: # once (75µs+0s) by Class::XSAccessor::Array::BEGIN@6 at line 2
use 5.008;
# spent 75µs making 1 call to Class::XSAccessor::BEGIN@2
3288µs251µs
# spent 40µs (28+12) within Class::XSAccessor::BEGIN@3 which was called: # once (28µs+12µs) by Class::XSAccessor::Array::BEGIN@6 at line 3
use strict;
# spent 40µs making 1 call to Class::XSAccessor::BEGIN@3 # spent 12µs making 1 call to strict::import
4298µs271µs
# spent 49µs (27+22) within Class::XSAccessor::BEGIN@4 which was called: # once (27µs+22µs) by Class::XSAccessor::Array::BEGIN@6 at line 4
use warnings;
# spent 49µs making 1 call to Class::XSAccessor::BEGIN@4 # spent 22µs making 1 call to warnings::import
5293µs2237µs
# spent 132µs (27+105) within Class::XSAccessor::BEGIN@5 which was called: # once (27µs+105µs) by Class::XSAccessor::Array::BEGIN@6 at line 5
use Carp qw/croak/;
# spent 132µs making 1 call to Class::XSAccessor::BEGIN@5 # spent 105µs making 1 call to Exporter::import
62397µs12.20ms
# spent 2.20ms (1.70+504µs) within Class::XSAccessor::BEGIN@6 which was called: # once (1.70ms+504µs) by Class::XSAccessor::Array::BEGIN@6 at line 6
use Class::XSAccessor::Heavy;
# spent 2.20ms making 1 call to Class::XSAccessor::BEGIN@6
721.79ms124µs
# spent 24µs within Class::XSAccessor::BEGIN@7 which was called: # once (24µs+0s) by Class::XSAccessor::Array::BEGIN@6 at line 7
use XSLoader;
# spent 24µs making 1 call to Class::XSAccessor::BEGIN@7
8
912µsour $VERSION = '1.13';
10
1111.23ms11.18msXSLoader::load('Class::XSAccessor', $VERSION);
# spent 1.18ms making 1 call to XSLoader::load
12
13
# spent 241µs within Class::XSAccessor::_make_hash which was called 24 times, avg 10µs/call: # 4 times (67µs+0s) by Class::XSAccessor::import at line 39, avg 17µs/call # 4 times (56µs+0s) by Class::XSAccessor::import at line 37, avg 14µs/call # 4 times (31µs+0s) by Class::XSAccessor::import at line 38, avg 8µs/call # 4 times (31µs+0s) by Class::XSAccessor::import at line 40, avg 8µs/call # 4 times (28µs+0s) by Class::XSAccessor::import at line 42, avg 7µs/call # 4 times (28µs+0s) by Class::XSAccessor::import at line 41, avg 7µs/call
sub _make_hash {
1472404µs my $ref = shift;
15
16 if (ref ($ref)) {
17 if (ref($ref) eq 'ARRAY') {
18 $ref = { map { $_ => $_ } @$ref }
19 }
20 } else {
21 $ref = { $ref, $ref };
22 }
23
24 return $ref;
25}
26
27
# spent 2.66ms (1.09+1.57) within Class::XSAccessor::import which was called 4 times, avg 665µs/call: # once (266µs+733µs) by Data::DPath::Point::BEGIN@14 at line 14 of Data/DPath/Point.pm # once (305µs+379µs) by Data::DPath::Attrs::BEGIN@14 at line 14 of Data/DPath/Attrs.pm # once (243µs+409µs) by Data::DPath::Path::BEGIN@20 at line 20 of Data/DPath/Path.pm # once (274µs+50µs) by Class::XSAccessor::Array::BEGIN@6 at line 6 of Class/XSAccessor/Array.pm
sub import {
28136945µs my $own_class = shift;
29 my ($caller_pkg) = caller();
30
31 # Support both { getters => ... } and plain getters => ...
32 my %opts = ref($_[0]) eq 'HASH' ? %{$_[0]} : @_;
33
34 $caller_pkg = $opts{class} if defined $opts{class};
35
36 # TODO: Refactor. Move more duplicated code to ::Heavy
37456µs my $read_subs = _make_hash($opts{getters} || {});
# spent 56µs making 4 calls to Class::XSAccessor::_make_hash, avg 14µs/call
38431µs my $set_subs = _make_hash($opts{setters} || {});
# spent 31µs making 4 calls to Class::XSAccessor::_make_hash, avg 8µs/call
39467µs my $acc_subs = _make_hash($opts{accessors} || {});
# spent 67µs making 4 calls to Class::XSAccessor::_make_hash, avg 17µs/call
40431µs my $lvacc_subs = _make_hash($opts{lvalue_accessors} || {});
# spent 31µs making 4 calls to Class::XSAccessor::_make_hash, avg 8µs/call
41428µs my $pred_subs = _make_hash($opts{predicates} || {});
# spent 28µs making 4 calls to Class::XSAccessor::_make_hash, avg 7µs/call
42428µs my $test_subs = _make_hash($opts{__tests__} || {});
# spent 28µs making 4 calls to Class::XSAccessor::_make_hash, avg 7µs/call
43 my $construct_subs = $opts{constructors} || [defined($opts{constructor}) ? $opts{constructor} : ()];
44 my $true_subs = $opts{true} || [];
45 my $false_subs = $opts{false} || [];
46
47 foreach my $subtype ( ["getter", $read_subs],
48 ["setter", $set_subs],
49 ["accessor", $acc_subs],
50 ["lvalue_accessor", $lvacc_subs],
51 ["test", $test_subs],
52 ["predicate", $pred_subs] )
53 {
54 my $subs = $subtype->[1];
55 foreach my $subname (keys %$subs) {
56 my $hashkey = $subs->{$subname};
5771.14ms _generate_method($caller_pkg, $subname, $hashkey, \%opts, $subtype->[0]);
# spent 1.14ms making 7 calls to Class::XSAccessor::_generate_method, avg 162µs/call
58 }
59 }
60
61 foreach my $subtype ( ["constructor", $construct_subs],
62 ["true", $true_subs],
63 ["false", $false_subs] )
64 {
65 foreach my $subname (@{$subtype->[1]}) {
662194µs _generate_method($caller_pkg, $subname, "", \%opts, $subtype->[0]);
# spent 194µs making 2 calls to Class::XSAccessor::_generate_method, avg 97µs/call
67 }
68 }
69}
70
71
# spent 1.33ms (431µs+899µs) within Class::XSAccessor::_generate_method which was called 9 times, avg 148µs/call: # 7 times (351µs+786µs) by Class::XSAccessor::import at line 57, avg 162µs/call # 2 times (80µs+114µs) by Class::XSAccessor::import at line 66, avg 97µs/call
sub _generate_method {
7252725µs my ($caller_pkg, $subname, $hashkey, $opts, $type) = @_;
73
74 croak("Cannot use undef as a hash key for generating an XS $type accessor. (Sub: $subname)")
75 if not defined $hashkey;
76
77933µs $subname = "${caller_pkg}::$subname" if $subname !~ /::/;
# spent 33µs making 9 calls to Class::XSAccessor::CORE:match, avg 4µs/call
78
799596µs Class::XSAccessor::Heavy::check_sub_existence($subname) if not $opts->{replace};
# spent 596µs making 9 calls to Class::XSAccessor::Heavy::check_sub_existence, avg 66µs/call
802834µs2141µs
# spent 89µs (37+52) within Class::XSAccessor::BEGIN@80 which was called: # once (37µs+52µs) by Class::XSAccessor::Array::BEGIN@6 at line 80
no warnings 'redefine'; # don't warn about an explicitly requested redefine
# spent 89µs making 1 call to Class::XSAccessor::BEGIN@80 # spent 52µs making 1 call to warnings::unimport
81
82228µs if ($type eq 'getter') {
# spent 28µs making 2 calls to Class::XSAccessor::newxs_constructor, avg 14µs/call
83 newxs_getter($subname, $hashkey);
84 }
85 elsif ($type eq 'lvalue_accessor') {
86 newxs_lvalue_accessor($subname, $hashkey);
87 }
88 elsif ($type eq 'setter') {
89 newxs_setter($subname, $hashkey, $opts->{chained}||0);
90 }
91 elsif ($type eq 'predicate') {
92 newxs_predicate($subname, $hashkey);
93 }
94 elsif ($type eq 'constructor') {
95 newxs_constructor($subname);
96 }
97 elsif ($type eq 'true') {
98 newxs_boolean($subname, 1);
99 }
100 elsif ($type eq 'false') {
101 newxs_boolean($subname, 0);
102 }
103 elsif ($type eq 'test') {
104 newxs_test($subname, $hashkey);
105 }
106 else {
1077242µs newxs_accessor($subname, $hashkey, $opts->{chained}||0);
# spent 242µs making 7 calls to Class::XSAccessor::newxs_accessor, avg 35µs/call
108 }
109}
110
111121µs1;
112
113__END__
 
# spent 33µs within Class::XSAccessor::CORE:match which was called 9 times, avg 4µs/call: # 9 times (33µs+0s) by Class::XSAccessor::_generate_method at line 77, avg 4µs/call
sub Class::XSAccessor::CORE:match; # opcode
# spent 8µs within Class::XSAccessor::END which was called: # once (8µs+0s) by main::RUNTIME at line 0 of bin/dpath
sub Class::XSAccessor::END; # xsub
# spent 242µs within Class::XSAccessor::newxs_accessor which was called 7 times, avg 35µs/call: # 7 times (242µs+0s) by Class::XSAccessor::_generate_method at line 107, avg 35µs/call
sub Class::XSAccessor::newxs_accessor; # xsub
# spent 28µs within Class::XSAccessor::newxs_constructor which was called 2 times, avg 14µs/call: # 2 times (28µs+0s) by Class::XSAccessor::_generate_method at line 82, avg 14µs/call
sub Class::XSAccessor::newxs_constructor; # xsub