Profile of Class/XSAccessor/Array.pm

← 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:48 2012

Filename | /home/ss5/perl5/perlbrew/perls/perl-5.14.1/lib/site_perl/5.14.1/x86_64-linux-thread-multi/Class/XSAccessor/Array.pm
Statements | Executed 129 statements in 4.02ms

Subroutines
Calls | P | F | Exclusive Time | Inclusive Time | Subroutine
--- | --- | --- | --- | --- | ---
1 | 1 | 1 | 3.38ms | 7.49ms | Class::XSAccessor::Array::::BEGIN@6Class::XSAccessor::Array::BEGIN@6
2 | 2 | 2 | 366µs | 1.29ms | Class::XSAccessor::Array::::importClass::XSAccessor::Array::import
7 | 2 | 1 | 350µs | 921µs | Class::XSAccessor::Array::::_generate_methodClass::XSAccessor::Array::_generate_method
5 | 1 | 1 | 153µs | 153µs | Class::XSAccessor::Array::::newxs_accessorClass::XSAccessor::Array::newxs_accessor (xsub)
1 | 1 | 1 | 89µs | 89µs | Class::XSAccessor::Array::::BEGIN@2Class::XSAccessor::Array::BEGIN@2
1 | 1 | 1 | 41µs | 104µs | Class::XSAccessor::Array::::BEGIN@62Class::XSAccessor::Array::BEGIN@62
1 | 1 | 1 | 40µs | 52µs | Class::XSAccessor::Array::::BEGIN@3Class::XSAccessor::Array::BEGIN@3
2 | 1 | 1 | 29µs | 29µs | Class::XSAccessor::Array::::newxs_constructorClass::XSAccessor::Array::newxs_constructor (xsub)
1 | 1 | 1 | 28µs | 286µs | Class::XSAccessor::Array::::BEGIN@5Class::XSAccessor::Array::BEGIN@5
1 | 1 | 1 | 27µs | 48µs | Class::XSAccessor::Array::::BEGIN@4Class::XSAccessor::Array::BEGIN@4
1 | 1 | 1 | 26µs | 26µs | Class::XSAccessor::Array::::BEGIN@7Class::XSAccessor::Array::BEGIN@7
7 | 1 | 1 | 26µs | 26µs | Class::XSAccessor::Array::::CORE:matchClass::XSAccessor::Array::CORE:match (opcode)

Call graph for these subroutines as a Graphviz dot language file.

Line | State ments | Time on line | Calls | Time in subs | Code
--- | --- | --- | --- | --- | ---
1 |  |  |  |  | package Class::XSAccessor::Array;
2 | 2 | 184µs | 1 | 89µs | # spent 89µs within Class::XSAccessor::Array::BEGIN@2 which was called: # once (89µs+0s) by Data::DPath::Step::BEGIN@14 at line 2 use 5.008; # spent 89µs making 1 call to Class::XSAccessor::Array::BEGIN@2
3 | 2 | 91µs | 2 | 63µs | # spent 52µs (40+12) within Class::XSAccessor::Array::BEGIN@3 which was called: # once (40µs+12µs) by Data::DPath::Step::BEGIN@14 at line 3 use strict; # spent 52µs making 1 call to Class::XSAccessor::Array::BEGIN@3 # spent 12µs making 1 call to strict::import
4 | 2 | 99µs | 2 | 68µs | # spent 48µs (27+20) within Class::XSAccessor::Array::BEGIN@4 which was called: # once (27µs+20µs) by Data::DPath::Step::BEGIN@14 at line 4 use warnings; # spent 48µs making 1 call to Class::XSAccessor::Array::BEGIN@4 # spent 20µs making 1 call to warnings::import
5 | 2 | 98µs | 2 | 545µs | # spent 286µs (28+259) within Class::XSAccessor::Array::BEGIN@5 which was called: # once (28µs+259µs) by Data::DPath::Step::BEGIN@14 at line 5 use Carp qw/croak/; # spent 286µs making 1 call to Class::XSAccessor::Array::BEGIN@5 # spent 259µs making 1 call to Exporter::import
6 | 2 | 454µs | 2 | 7.82ms | # spent 7.49ms (3.38+4.12) within Class::XSAccessor::Array::BEGIN@6 which was called: # once (3.38ms+4.12ms) by Data::DPath::Step::BEGIN@14 at line 6 use Class::XSAccessor; # spent 7.49ms making 1 call to Class::XSAccessor::Array::BEGIN@6 # spent 324µs making 1 call to Class::XSAccessor::import
7 | 2 | 1.48ms | 1 | 26µs | # spent 26µs within Class::XSAccessor::Array::BEGIN@7 which was called: # once (26µs+0s) by Data::DPath::Step::BEGIN@14 at line 7 use Class::XSAccessor::Heavy; # spent 26µs making 1 call to Class::XSAccessor::Array::BEGIN@7
8 |  |  |  |  |
9 | 1 | 2µs |  |  | our $VERSION = '1.13';
10 |  |  |  |  |
11 |  |  |  |  | # spent 1.29ms (366µs+921µs) within Class::XSAccessor::Array::import which was called 2 times, avg 643µs/call: # once (189µs+565µs) by Data::DPath::Step::BEGIN@14 at line 14 of Data/DPath/Step.pm # once (178µs+356µs) by Data::DPath::Context::BEGIN@57 at line 57 of Data/DPath/Context.pm sub import {
12 | 2 | 5µs |  |  | my $own_class = shift;
13 | 2 | 13µs |  |  | my ($caller_pkg) = caller();
14 |  |  |  |  |
15 |  |  |  |  | # Support both { getters => ... } and plain getters => ...
16 | 2 | 22µs |  |  | my %opts = ref($_[0]) eq 'HASH' ? %{$_[0]} : @_;
17 |  |  |  |  |
18 | 2 | 4µs |  |  | $caller_pkg = $opts{class} if defined $opts{class};
19 |  |  |  |  |
20 | 2 | 6µs |  |  | my $read_subs = $opts{getters} || {};
21 | 2 | 4µs |  |  | my $set_subs = $opts{setters} || {};
22 | 2 | 3µs |  |  | my $acc_subs = $opts{accessors} || {};
23 | 2 | 4µs |  |  | my $lvacc_subs = $opts{lvalue_accessors} || {};
24 | 2 | 4µs |  |  | my $pred_subs = $opts{predicates} || {};
25 | 2 | 11µs |  |  | my $construct_subs = $opts{constructors} || [defined($opts{constructor}) ? $opts{constructor} : ()];
26 | 2 | 4µs |  |  | my $true_subs = $opts{true} || [];
27 | 2 | 4µs |  |  | my $false_subs = $opts{false} || [];
28 |  |  |  |  |
29 |  |  |  |  |
30 | 2 | 32µs |  |  | foreach my $subtype ( ["getter", $read_subs],
31 |  |  |  |  | ["setter", $set_subs],
32 |  |  |  |  | ["accessor", $acc_subs],
33 |  |  |  |  | ["lvalue_accessor", $lvacc_subs],
34 |  |  |  |  | ["pred_subs", $pred_subs] )
35 |  |  |  |  | {
36 | 10 | 17µs |  |  | my $subs = $subtype->[1];
37 | 10 | 72µs |  |  | foreach my $subname (keys %$subs) {
38 | 5 | 11µs |  |  | my $array_index = $subs->{$subname};
39 | 5 | 49µs | 5 | 722µs | _generate_method($caller_pkg, $subname, $array_index, \%opts, $subtype->[0]); # spent 722µs making 5 calls to Class::XSAccessor::Array::_generate_method, avg 144µs/call
40 |  |  |  |  | }
41 |  |  |  |  | }
42 |  |  |  |  |
43 | 2 | 54µs |  |  | foreach my $subtype ( ["constructor", $construct_subs],
44 |  |  |  |  | ["true", $true_subs],
45 |  |  |  |  | ["false", $false_subs] )
46 |  |  |  |  | {
47 | 6 | 24µs |  |  | foreach my $subname (@{$subtype->[1]}) {
48 | 2 | 19µs | 2 | 198µs | _generate_method($caller_pkg, $subname, "", \%opts, $subtype->[0]); # spent 198µs making 2 calls to Class::XSAccessor::Array::_generate_method, avg 99µs/call
49 |  |  |  |  | }
50 |  |  |  |  | }
51 |  |  |  |  | }
52 |  |  |  |  |
53 |  |  |  |  | # spent 921µs (350+571) within Class::XSAccessor::Array::_generate_method which was called 7 times, avg 132µs/call: # 5 times (265µs+457µs) by Class::XSAccessor::Array::import at line 39, avg 144µs/call # 2 times (85µs+114µs) by Class::XSAccessor::Array::import at line 48, avg 99µs/call sub _generate_method {
54 | 7 | 27µs |  |  | my ($caller_pkg, $subname, $array_index, $opts, $type) = @_;
55 |  |  |  |  |
56 | 7 | 7µs |  |  | croak("Cannot use undef as a array index for generating an XS $type accessor. (Sub: $subname)")
57 |  |  |  |  | if not defined $array_index;
58 |  |  |  |  |
59 | 7 | 119µs | 7 | 26µs | $subname = "${caller_pkg}::$subname" if $subname !~ /::/; # spent 26µs making 7 calls to Class::XSAccessor::Array::CORE:match, avg 4µs/call
60 |  |  |  |  |
61 | 7 | 45µs | 7 | 362µs | Class::XSAccessor::Heavy::check_sub_existence($subname) if not $opts->{replace}; # spent 362µs making 7 calls to Class::XSAccessor::Heavy::check_sub_existence, avg 52µs/call
62 | 2 | 695µs | 2 | 166µs | # spent 104µs (41+62) within Class::XSAccessor::Array::BEGIN@62 which was called: # once (41µs+62µs) by Data::DPath::Step::BEGIN@14 at line 62 no warnings 'redefine'; # don't warn about an explicitly requested redefine # spent 104µs making 1 call to Class::XSAccessor::Array::BEGIN@62 # spent 62µs making 1 call to warnings::unimport
63 |  |  |  |  |
64 | 7 | 8µs |  |  | if ($type eq 'getter') {
65 |  |  |  |  | newxs_getter($subname, $array_index);
66 |  |  |  |  | }
67 | 7 | 126µs | 2 | 29µs | if ($type eq 'lvalue_accessor') { # spent 29µs making 2 calls to Class::XSAccessor::Array::newxs_constructor, avg 14µs/call
68 |  |  |  |  | newxs_lvalue_accessor($subname, $array_index);
69 |  |  |  |  | }
70 |  |  |  |  | elsif ($type eq 'setter') {
71 |  |  |  |  | newxs_setter($subname, $array_index, $opts->{chained}||0);
72 |  |  |  |  | }
73 |  |  |  |  | elsif ($type eq 'predicate') {
74 |  |  |  |  | newxs_predicate($subname, $array_index);
75 |  |  |  |  | }
76 |  |  |  |  | elsif ($type eq 'constructor') {
77 |  |  |  |  | newxs_constructor($subname);
78 |  |  |  |  | }
79 |  |  |  |  | elsif ($type eq 'true') {
80 |  |  |  |  | Class::XSAccessor::newxs_boolean($subname, 1);
81 |  |  |  |  | }
82 |  |  |  |  | elsif ($type eq 'false') {
83 |  |  |  |  | Class::XSAccessor::newxs_boolean($subname, 0);
84 |  |  |  |  | }
85 |  |  |  |  | else {
86 | 5 | 214µs | 5 | 153µs | newxs_accessor($subname, $array_index, $opts->{chained}||0); # spent 153µs making 5 calls to Class::XSAccessor::Array::newxs_accessor, avg 31µs/call
87 |  |  |  |  | }
88 |  |  |  |  | }
89 |  |  |  |  |
90 | 1 | 10µs |  |  | 1;
91 |  |  |  |  |
92 |  |  |  |  | __END__
|  |  |  |  | # spent 26µs within Class::XSAccessor::Array::CORE:match which was called 7 times, avg 4µs/call: # 7 times (26µs+0s) by Class::XSAccessor::Array::_generate_method at line 59, avg 4µs/call sub Class::XSAccessor::Array::CORE:match; # opcode
|  |  |  |  | # spent 153µs within Class::XSAccessor::Array::newxs_accessor which was called 5 times, avg 31µs/call: # 5 times (153µs+0s) by Class::XSAccessor::Array::_generate_method at line 86, avg 31µs/call sub Class::XSAccessor::Array::newxs_accessor; # xsub
|  |  |  |  | # spent 29µs within Class::XSAccessor::Array::newxs_constructor which was called 2 times, avg 14µs/call: # 2 times (29µs+0s) by Class::XSAccessor::Array::_generate_method at line 67, avg 14µs/call sub Class::XSAccessor::Array::newxs_constructor; # xsub