← 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/x86_64-linux/Class/XSAccessor.pm
StatementsExecuted 277 statements in 1.11ms
Subroutines
Calls P F Exclusive
Time
Inclusive
Time
Subroutine
111250µs360µsClass::XSAccessor::::BEGIN@6Class::XSAccessor::BEGIN@6
444160µs403µsClass::XSAccessor::::importClass::XSAccessor::import
92185µs209µsClass::XSAccessor::::_generate_methodClass::XSAccessor::_generate_method
71137µs37µsClass::XSAccessor::::newxs_accessorClass::XSAccessor::newxs_accessor (xsub)
246134µs34µsClass::XSAccessor::::_make_hashClass::XSAccessor::_make_hash
11112µs12µsClass::XSAccessor::::BEGIN@2Class::XSAccessor::BEGIN@2
1119µs12µsClass::XSAccessor::::BEGIN@4Class::XSAccessor::BEGIN@4
1118µs19µsClass::XSAccessor::::BEGIN@80Class::XSAccessor::BEGIN@80
1116µs26µsClass::XSAccessor::::BEGIN@5Class::XSAccessor::BEGIN@5
1116µs15µsClass::XSAccessor::::BEGIN@3Class::XSAccessor::BEGIN@3
2114µs4µsClass::XSAccessor::::newxs_constructorClass::XSAccessor::newxs_constructor (xsub)
1114µs4µsClass::XSAccessor::::BEGIN@7Class::XSAccessor::BEGIN@7
9114µs4µsClass::XSAccessor::::CORE:matchClass::XSAccessor::CORE:match (opcode)
1112µs2µ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;
2236µs112µs
# spent 12µs within Class::XSAccessor::BEGIN@2 which was called: # once (12µs+0s) by Class::XSAccessor::Array::BEGIN@6 at line 2
use 5.008;
# spent 12µs making 1 call to Class::XSAccessor::BEGIN@2
3216µs224µs
# spent 15µs (6+9) within Class::XSAccessor::BEGIN@3 which was called: # once (6µs+9µs) by Class::XSAccessor::Array::BEGIN@6 at line 3
use strict;
# spent 15µs making 1 call to Class::XSAccessor::BEGIN@3 # spent 9µs making 1 call to strict::import
4218µs215µs
# spent 12µs (9+3) within Class::XSAccessor::BEGIN@4 which was called: # once (9µs+3µs) by Class::XSAccessor::Array::BEGIN@6 at line 4
use warnings;
# spent 12µs making 1 call to Class::XSAccessor::BEGIN@4 # spent 3µs making 1 call to warnings::import
5222µs246µs
# spent 26µs (6+20) within Class::XSAccessor::BEGIN@5 which was called: # once (6µs+20µs) by Class::XSAccessor::Array::BEGIN@6 at line 5
use Carp qw/croak/;
# spent 26µs making 1 call to Class::XSAccessor::BEGIN@5 # spent 20µs making 1 call to Exporter::import
6265µs1360µs
# spent 360µs (250+110) within Class::XSAccessor::BEGIN@6 which was called: # once (250µs+110µs) by Class::XSAccessor::Array::BEGIN@6 at line 6
use Class::XSAccessor::Heavy;
# spent 360µs making 1 call to Class::XSAccessor::BEGIN@6
72284µs14µs
# spent 4µs within Class::XSAccessor::BEGIN@7 which was called: # once (4µs+0s) by Class::XSAccessor::Array::BEGIN@6 at line 7
use XSLoader;
# spent 4µs making 1 call to Class::XSAccessor::BEGIN@7
8
91400nsour $VERSION = '1.16';
10
111222µs1217µsXSLoader::load('Class::XSAccessor', $VERSION);
# spent 217µs making 1 call to XSLoader::load
12
13
# spent 34µs within Class::XSAccessor::_make_hash which was called 24 times, avg 1µs/call: # 4 times (11µs+0s) by Class::XSAccessor::import at line 39, avg 3µs/call # 4 times (9µs+0s) by Class::XSAccessor::import at line 37, avg 2µs/call # 4 times (4µs+0s) by Class::XSAccessor::import at line 38, avg 1µs/call # 4 times (4µs+0s) by Class::XSAccessor::import at line 40, avg 925ns/call # 4 times (4µs+0s) by Class::XSAccessor::import at line 42, avg 900ns/call # 4 times (3µs+0s) by Class::XSAccessor::import at line 41, avg 850ns/call
sub _make_hash {
14244µs my $ref = shift;
15
162414µs if (ref ($ref)) {
17 if (ref($ref) eq 'ARRAY') {
18 $ref = { map { $_ => $_ } @$ref }
19 }
20 } else {
21 $ref = { $ref, $ref };
22 }
23
242444µs return $ref;
25}
26
27
# spent 403µs (160+243) within Class::XSAccessor::import which was called 4 times, avg 101µs/call: # once (42µs+109µs) by Data::DPath::Point::BEGIN@14 at line 14 of Data/DPath/Point.pm # once (46µs+79µs) by Data::DPath::Path::BEGIN@20 at line 20 of Data/DPath/Path.pm # once (37µs+48µs) by Data::DPath::Attrs::BEGIN@14 at line 14 of Data/DPath/Attrs.pm # once (34µs+7µs) by Class::XSAccessor::Array::BEGIN@6 at line 6 of Class/XSAccessor/Array.pm
sub import {
2842µs my $own_class = shift;
2944µs my ($caller_pkg) = caller();
30
31 # Support both { getters => ... } and plain getters => ...
3247µs my %opts = ref($_[0]) eq 'HASH' ? %{$_[0]} : @_;
33
3441µs $caller_pkg = $opts{class} if defined $opts{class};
35
36 # TODO: Refactor. Move more duplicated code to ::Heavy
3747µs49µs my $read_subs = _make_hash($opts{getters} || {});
# spent 9µs making 4 calls to Class::XSAccessor::_make_hash, avg 2µs/call
3844µs44µs my $set_subs = _make_hash($opts{setters} || {});
# spent 4µs making 4 calls to Class::XSAccessor::_make_hash, avg 1µs/call
3944µs411µs my $acc_subs = _make_hash($opts{accessors} || {});
# spent 11µs making 4 calls to Class::XSAccessor::_make_hash, avg 3µs/call
4044µs44µs my $lvacc_subs = _make_hash($opts{lvalue_accessors} || {});
# spent 4µs making 4 calls to Class::XSAccessor::_make_hash, avg 925ns/call
4144µs43µs my $pred_subs = _make_hash($opts{predicates} || {});
# spent 3µs making 4 calls to Class::XSAccessor::_make_hash, avg 850ns/call
4243µs44µs my $test_subs = _make_hash($opts{__tests__} || {});
# spent 4µs making 4 calls to Class::XSAccessor::_make_hash, avg 900ns/call
4343µs my $construct_subs = $opts{constructors} || [defined($opts{constructor}) ? $opts{constructor} : ()];
4441µs my $true_subs = $opts{true} || [];
4541µs my $false_subs = $opts{false} || [];
46
47411µs 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 {
54245µs my $subs = $subtype->[1];
552423µs foreach my $subname (keys %$subs) {
5673µs my $hashkey = $subs->{$subname};
57712µs7174µs _generate_method($caller_pkg, $subname, $hashkey, \%opts, $subtype->[0]);
# spent 174µs making 7 calls to Class::XSAccessor::_generate_method, avg 25µs/call
58 }
59 }
60
61422µs foreach my $subtype ( ["constructor", $construct_subs],
62 ["true", $true_subs],
63 ["false", $false_subs] )
64 {
65127µs foreach my $subname (@{$subtype->[1]}) {
6623µs235µs _generate_method($caller_pkg, $subname, "", \%opts, $subtype->[0]);
# spent 35µs making 2 calls to Class::XSAccessor::_generate_method, avg 18µs/call
67 }
68 }
69}
70
71
# spent 209µs (85+124) within Class::XSAccessor::_generate_method which was called 9 times, avg 23µs/call: # 7 times (69µs+105µs) by Class::XSAccessor::import at line 57, avg 25µs/call # 2 times (16µs+19µs) by Class::XSAccessor::import at line 66, avg 18µs/call
sub _generate_method {
7296µs my ($caller_pkg, $subname, $hashkey, $opts, $type) = @_;
73
7492µs croak("Cannot use undef as a hash key for generating an XS $type accessor. (Sub: $subname)")
75 if not defined $hashkey;
76
77926µs94µs $subname = "${caller_pkg}::$subname" if $subname !~ /::/;
# spent 4µs making 9 calls to Class::XSAccessor::CORE:match, avg 456ns/call
78
79911µs978µs Class::XSAccessor::Heavy::check_sub_existence($subname) if not $opts->{replace};
# spent 78µs making 9 calls to Class::XSAccessor::Heavy::check_sub_existence, avg 9µs/call
802116µs231µs
# spent 19µs (8+11) within Class::XSAccessor::BEGIN@80 which was called: # once (8µs+11µs) by Class::XSAccessor::Array::BEGIN@6 at line 80
no warnings 'redefine'; # don't warn about an explicitly requested redefine
# spent 19µs making 1 call to Class::XSAccessor::BEGIN@80 # spent 11µs making 1 call to warnings::unimport
81
82930µs24µs if ($type eq 'getter') {
# spent 4µs making 2 calls to Class::XSAccessor::newxs_constructor, avg 2µ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 {
107754µs737µs newxs_accessor($subname, $hashkey, $opts->{chained}||0);
# spent 37µs making 7 calls to Class::XSAccessor::newxs_accessor, avg 5µs/call
108 }
109}
110
11113µs1;
112
113__END__
 
# spent 4µs within Class::XSAccessor::CORE:match which was called 9 times, avg 456ns/call: # 9 times (4µs+0s) by Class::XSAccessor::_generate_method at line 77, avg 456ns/call
sub Class::XSAccessor::CORE:match; # opcode
# spent 2µs within Class::XSAccessor::END which was called: # once (2µs+0s) by main::RUNTIME at line 0 of bin/benchmark-perlformance
sub Class::XSAccessor::END; # xsub
# spent 37µs within Class::XSAccessor::newxs_accessor which was called 7 times, avg 5µs/call: # 7 times (37µs+0s) by Class::XSAccessor::_generate_method at line 107, avg 5µs/call
sub Class::XSAccessor::newxs_accessor; # xsub
# spent 4µs within Class::XSAccessor::newxs_constructor which was called 2 times, avg 2µs/call: # 2 times (4µs+0s) by Class::XSAccessor::_generate_method at line 82, avg 2µs/call
sub Class::XSAccessor::newxs_constructor; # xsub