← Index
NYTProf Performance Profile   « line view »
For /home/ss5/perl5/perlbrew/perls/perl-5.22.0/bin/benchmarkanything-storage
  Run on Mon Jan 29 16:55:34 2018
Reported on Mon Jan 29 16:57:07 2018

Filename/home/ss5/perl5/perlbrew/perls/perl-5.22.0/lib/site_perl/5.22.0/x86_64-linux/Class/XSAccessor.pm
StatementsExecuted 4245 statements in 3.09ms
Subroutines
Calls P F Exclusive
Time
Inclusive
Time
Subroutine
63111.53ms2.31msClass::XSAccessor::::importClass::XSAccessor::import
6311290µs552µsClass::XSAccessor::::_generate_methodClass::XSAccessor::_generate_method
50481235µs235µsClass::XSAccessor::::_make_hashClass::XSAccessor::_make_hash
111225µs303µsClass::XSAccessor::::BEGIN@6Class::XSAccessor::BEGIN@6
5211216µs216µsClass::XSAccessor::::newxs_getterClass::XSAccessor::newxs_getter (xsub)
631119µs19µsClass::XSAccessor::::CORE:matchClass::XSAccessor::CORE:match (opcode)
71118µs18µsClass::XSAccessor::::newxs_accessorClass::XSAccessor::newxs_accessor (xsub)
11116µs16µsClass::XSAccessor::::BEGIN@2Class::XSAccessor::BEGIN@2
3117µs7µsClass::XSAccessor::::newxs_setterClass::XSAccessor::newxs_setter (xsub)
1116µs14µsClass::XSAccessor::::BEGIN@84Class::XSAccessor::BEGIN@84
1116µs17µsClass::XSAccessor::::BEGIN@3Class::XSAccessor::BEGIN@3
1115µs22µsClass::XSAccessor::::BEGIN@5Class::XSAccessor::BEGIN@5
1115µs8µsClass::XSAccessor::::BEGIN@4Class::XSAccessor::BEGIN@4
1114µs4µsClass::XSAccessor::::BEGIN@7Class::XSAccessor::BEGIN@7
1113µs3µsClass::XSAccessor::::ENDClass::XSAccessor::END (xsub)
1112µs2µsClass::XSAccessor::::newxs_exists_predicateClass::XSAccessor::newxs_exists_predicate (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;
2260µs116µs
# spent 16µs within Class::XSAccessor::BEGIN@2 which was called: # once (16µs+0s) by Module::Runtime::require_module at line 2
use 5.008;
# spent 16µs making 1 call to Class::XSAccessor::BEGIN@2
3213µs228µs
# spent 17µs (6+11) within Class::XSAccessor::BEGIN@3 which was called: # once (6µs+11µs) by Module::Runtime::require_module at line 3
use strict;
# spent 17µs making 1 call to Class::XSAccessor::BEGIN@3 # spent 11µs making 1 call to strict::import
4216µs211µs
# spent 8µs (5+3) within Class::XSAccessor::BEGIN@4 which was called: # once (5µs+3µs) by Module::Runtime::require_module at line 4
use warnings;
# spent 8µs making 1 call to Class::XSAccessor::BEGIN@4 # spent 3µs making 1 call to warnings::import
5215µs238µs
# spent 22µs (5+17) within Class::XSAccessor::BEGIN@5 which was called: # once (5µs+17µs) by Module::Runtime::require_module at line 5
use Carp qw/croak/;
# spent 22µs making 1 call to Class::XSAccessor::BEGIN@5 # spent 17µs making 1 call to Exporter::import
6258µs1303µs
# spent 303µs (225+78) within Class::XSAccessor::BEGIN@6 which was called: # once (225µs+78µs) by Module::Runtime::require_module at line 6
use Class::XSAccessor::Heavy;
# spent 303µs making 1 call to Class::XSAccessor::BEGIN@6
72274µs14µs
# spent 4µs within Class::XSAccessor::BEGIN@7 which was called: # once (4µs+0s) by Module::Runtime::require_module at line 7
use XSLoader;
# spent 4µs making 1 call to Class::XSAccessor::BEGIN@7
8
91300nsour $VERSION = '1.19';
10
111208µs1204µsXSLoader::load('Class::XSAccessor', $VERSION);
# spent 204µs making 1 call to XSLoader::load
12
13
# spent 235µs within Class::XSAccessor::_make_hash which was called 504 times, avg 466ns/call: # 63 times (63µs+0s) by Class::XSAccessor::import at line 37, avg 995ns/call # 63 times (27µs+0s) by Class::XSAccessor::import at line 38, avg 427ns/call # 63 times (26µs+0s) by Class::XSAccessor::import at line 40, avg 405ns/call # 63 times (25µs+0s) by Class::XSAccessor::import at line 39, avg 390ns/call # 63 times (24µs+0s) by Class::XSAccessor::import at line 43, avg 386ns/call # 63 times (24µs+0s) by Class::XSAccessor::import at line 41, avg 378ns/call # 63 times (24µs+0s) by Class::XSAccessor::import at line 44, avg 373ns/call # 63 times (23µs+0s) by Class::XSAccessor::import at line 42, avg 371ns/call
sub _make_hash {
1450441µs my $ref = shift;
15
1650476µs if (ref ($ref)) {
17 if (ref($ref) eq 'ARRAY') {
18 $ref = { map { $_ => $_ } @$ref }
19 }
20 } else {
21 $ref = { $ref, $ref };
22 }
23
24504407µs return $ref;
25}
26
27
# spent 2.31ms (1.53+787µs) within Class::XSAccessor::import which was called 63 times, avg 37µs/call: # 63 times (1.53ms+787µs) by Method::Generate::Accessor::_generate_xs at line 646 of Method/Generate/Accessor.pm, avg 37µs/call
sub import {
286311µs my $own_class = shift;
296337µs my ($caller_pkg) = caller();
30
31 # Support both { getters => ... } and plain getters => ...
326362µs my %opts = ref($_[0]) eq 'HASH' ? %{$_[0]} : @_;
33
346328µs $caller_pkg = $opts{class} if defined $opts{class};
35
36 # TODO: Refactor. Move more duplicated code to ::Heavy
376350µs6363µs my $read_subs = _make_hash($opts{getters} || {});
# spent 63µs making 63 calls to Class::XSAccessor::_make_hash, avg 995ns/call
386339µs6327µs my $set_subs = _make_hash($opts{setters} || {});
# spent 27µs making 63 calls to Class::XSAccessor::_make_hash, avg 427ns/call
396333µs6325µs my $acc_subs = _make_hash($opts{accessors} || {});
# spent 25µs making 63 calls to Class::XSAccessor::_make_hash, avg 390ns/call
406331µs6326µs my $lvacc_subs = _make_hash($opts{lvalue_accessors} || {});
# spent 26µs making 63 calls to Class::XSAccessor::_make_hash, avg 405ns/call
416331µs6324µs my $pred_subs = _make_hash($opts{predicates} || {});
# spent 24µs making 63 calls to Class::XSAccessor::_make_hash, avg 378ns/call
426330µs6323µs my $ex_pred_subs = _make_hash($opts{exists_predicates} || {});
# spent 23µs making 63 calls to Class::XSAccessor::_make_hash, avg 371ns/call
436331µs6324µs my $def_pred_subs = _make_hash($opts{defined_predicates} || {});
# spent 24µs making 63 calls to Class::XSAccessor::_make_hash, avg 386ns/call
446329µs6324µs my $test_subs = _make_hash($opts{__tests__} || {});
# spent 24µs making 63 calls to Class::XSAccessor::_make_hash, avg 373ns/call
456325µs my $construct_subs = $opts{constructors} || [defined($opts{constructor}) ? $opts{constructor} : ()];
466313µs my $true_subs = $opts{true} || [];
476312µs my $false_subs = $opts{false} || [];
48
4963160µs foreach my $subtype ( ["getter", $read_subs],
50 ["setter", $set_subs],
51 ["accessor", $acc_subs],
52 ["lvalue_accessor", $lvacc_subs],
53 ["test", $test_subs],
54 ["ex_predicate", $ex_pred_subs],
55 ["def_predicate", $def_pred_subs],
56 ["def_predicate", $pred_subs] )
57 {
5850450µs my $subs = $subtype->[1];
59504262µs foreach my $subname (keys %$subs) {
606312µs my $hashkey = $subs->{$subname};
616364µs63552µs _generate_method($caller_pkg, $subname, $hashkey, \%opts, $subtype->[0]);
# spent 552µs making 63 calls to Class::XSAccessor::_generate_method, avg 9µs/call
62 }
63 }
64
6563171µs foreach my $subtype ( ["constructor", $construct_subs],
66 ["true", $true_subs],
67 ["false", $false_subs] )
68 {
6918965µs foreach my $subname (@{$subtype->[1]}) {
70 _generate_method($caller_pkg, $subname, "", \%opts, $subtype->[0]);
71 }
72 }
73}
74
75
# spent 552µs (290+262) within Class::XSAccessor::_generate_method which was called 63 times, avg 9µs/call: # 63 times (290µs+262µs) by Class::XSAccessor::import at line 61, avg 9µs/call
sub _generate_method {
766322µs my ($caller_pkg, $subname, $hashkey, $opts, $type) = @_;
77
786311µs croak("Cannot use undef as a hash key for generating an XS $type accessor. (Sub: $subname)")
79 if not defined $hashkey;
80
8163112µs6319µs $subname = "${caller_pkg}::$subname" if $subname !~ /::/;
# spent 19µs making 63 calls to Class::XSAccessor::CORE:match, avg 297ns/call
82
836324µs Class::XSAccessor::Heavy::check_sub_existence($subname) if not $opts->{replace};
84297µs222µs
# spent 14µs (6+8) within Class::XSAccessor::BEGIN@84 which was called: # once (6µs+8µs) by Module::Runtime::require_module at line 84
no warnings 'redefine'; # don't warn about an explicitly requested redefine
# spent 14µs making 1 call to Class::XSAccessor::BEGIN@84 # spent 8µs making 1 call to warnings::unimport
85
8663378µs56225µs if ($type eq 'getter') {
# spent 216µs making 52 calls to Class::XSAccessor::newxs_getter, avg 4µs/call # spent 7µs making 3 calls to Class::XSAccessor::newxs_setter, avg 2µs/call # spent 2µs making 1 call to Class::XSAccessor::newxs_exists_predicate
87 newxs_getter($subname, $hashkey);
88 }
89 elsif ($type eq 'lvalue_accessor') {
90 newxs_lvalue_accessor($subname, $hashkey);
91 }
92 elsif ($type eq 'setter') {
93 newxs_setter($subname, $hashkey, $opts->{chained}||0);
94 }
95 elsif ($type eq 'def_predicate') {
96 newxs_defined_predicate($subname, $hashkey);
97 }
98 elsif ($type eq 'ex_predicate') {
99 newxs_exists_predicate($subname, $hashkey);
100 }
101 elsif ($type eq 'constructor') {
102 newxs_constructor($subname);
103 }
104 elsif ($type eq 'true') {
105 newxs_boolean($subname, 1);
106 }
107 elsif ($type eq 'false') {
108 newxs_boolean($subname, 0);
109 }
110 elsif ($type eq 'test') {
111 newxs_test($subname, $hashkey);
112 }
113 else {
114733µs718µs newxs_accessor($subname, $hashkey, $opts->{chained}||0);
# spent 18µs making 7 calls to Class::XSAccessor::newxs_accessor, avg 3µs/call
115 }
116}
117
11813µs1;
119
120__END__
 
# spent 19µs within Class::XSAccessor::CORE:match which was called 63 times, avg 297ns/call: # 63 times (19µs+0s) by Class::XSAccessor::_generate_method at line 81, avg 297ns/call
sub Class::XSAccessor::CORE:match; # opcode
# spent 3µs within Class::XSAccessor::END which was called: # once (3µs+0s) by main::RUNTIME at line 0 of /home/ss5/perl5/perlbrew/perls/perl-5.22.0/bin/benchmarkanything-storage
sub Class::XSAccessor::END; # xsub
# spent 18µs within Class::XSAccessor::newxs_accessor which was called 7 times, avg 3µs/call: # 7 times (18µs+0s) by Class::XSAccessor::_generate_method at line 114, avg 3µs/call
sub Class::XSAccessor::newxs_accessor; # xsub
# spent 2µs within Class::XSAccessor::newxs_exists_predicate which was called: # once (2µs+0s) by Class::XSAccessor::_generate_method at line 86
sub Class::XSAccessor::newxs_exists_predicate; # xsub
# spent 216µs within Class::XSAccessor::newxs_getter which was called 52 times, avg 4µs/call: # 52 times (216µs+0s) by Class::XSAccessor::_generate_method at line 86, avg 4µs/call
sub Class::XSAccessor::newxs_getter; # xsub
# spent 7µs within Class::XSAccessor::newxs_setter which was called 3 times, avg 2µs/call: # 3 times (7µs+0s) by Class::XSAccessor::_generate_method at line 86, avg 2µs/call
sub Class::XSAccessor::newxs_setter; # xsub