← Index
NYTProf Performance Profile   « line view »
For index.cgi
  Run on Sat May 9 17:18:47 2020
Reported on Sat May 9 17:19:07 2020

Filename/usr/local/lib/perl/5.18.2/Class/XSAccessor.pm
StatementsExecuted 624 statements in 2.29ms
Subroutines
Calls P F Exclusive
Time
Inclusive
Time
Subroutine
911567µs860µsClass::XSAccessor::::importClass::XSAccessor::import
111486µs667µsClass::XSAccessor::::BEGIN@6Class::XSAccessor::BEGIN@6
7281112µs112µsClass::XSAccessor::::_make_hashClass::XSAccessor::_make_hash
911101µs181µsClass::XSAccessor::::_generate_methodClass::XSAccessor::_generate_method
41142µs42µsClass::XSAccessor::::newxs_accessorClass::XSAccessor::newxs_accessor (xsub)
51130µs30µsClass::XSAccessor::::newxs_getterClass::XSAccessor::newxs_getter (xsub)
11119µs19µsClass::XSAccessor::::BEGIN@2Class::XSAccessor::BEGIN@2
11113µs27µsClass::XSAccessor::::BEGIN@84Class::XSAccessor::BEGIN@84
11110µs69µsClass::XSAccessor::::BEGIN@5Class::XSAccessor::BEGIN@5
1119µs15µsClass::XSAccessor::::BEGIN@4Class::XSAccessor::BEGIN@4
1119µs26µsClass::XSAccessor::::BEGIN@3Class::XSAccessor::BEGIN@3
9118µs8µsClass::XSAccessor::::CORE:matchClass::XSAccessor::CORE:match (opcode)
1116µs6µsClass::XSAccessor::::BEGIN@7Class::XSAccessor::BEGIN@7
1114µs4µ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;
2264µs119µs
# spent 19µs within Class::XSAccessor::BEGIN@2 which was called: # once (19µs+0s) by Module::Runtime::require_module at line 2
use 5.008;
# spent 19µs making 1 call to Class::XSAccessor::BEGIN@2
3230µs243µs
# spent 26µs (9+17) within Class::XSAccessor::BEGIN@3 which was called: # once (9µs+17µs) by Module::Runtime::require_module at line 3
use strict;
# spent 26µs making 1 call to Class::XSAccessor::BEGIN@3 # spent 17µs making 1 call to strict::import
4278µs221µs
# spent 15µs (9+6) within Class::XSAccessor::BEGIN@4 which was called: # once (9µs+6µs) by Module::Runtime::require_module at line 4
use warnings;
# spent 15µs making 1 call to Class::XSAccessor::BEGIN@4 # spent 6µs making 1 call to warnings::import
5235µs2128µs
# spent 69µs (10+59) within Class::XSAccessor::BEGIN@5 which was called: # once (10µs+59µs) by Module::Runtime::require_module at line 5
use Carp qw/croak/;
# spent 69µs making 1 call to Class::XSAccessor::BEGIN@5 # spent 59µs making 1 call to Exporter::import
62124µs1667µs
# spent 667µs (486+181) within Class::XSAccessor::BEGIN@6 which was called: # once (486µs+181µs) by Module::Runtime::require_module at line 6
use Class::XSAccessor::Heavy;
# spent 667µs making 1 call to Class::XSAccessor::BEGIN@6
72563µs16µs
# spent 6µs within Class::XSAccessor::BEGIN@7 which was called: # once (6µs+0s) by Module::Runtime::require_module at line 7
use XSLoader;
# spent 6µs making 1 call to Class::XSAccessor::BEGIN@7
8
91900nsour $VERSION = '1.19';
10
111278µs1268µsXSLoader::load('Class::XSAccessor', $VERSION);
# spent 268µs making 1 call to XSLoader::load
12
13
# spent 112µs within Class::XSAccessor::_make_hash which was called 72 times, avg 2µs/call: # 9 times (20µs+0s) by Class::XSAccessor::import at line 37, avg 2µs/call # 9 times (14µs+0s) by Class::XSAccessor::import at line 38, avg 2µs/call # 9 times (13µs+0s) by Class::XSAccessor::import at line 39, avg 1µs/call # 9 times (13µs+0s) by Class::XSAccessor::import at line 40, avg 1µs/call # 9 times (13µs+0s) by Class::XSAccessor::import at line 44, avg 1µs/call # 9 times (13µs+0s) by Class::XSAccessor::import at line 41, avg 1µs/call # 9 times (13µs+0s) by Class::XSAccessor::import at line 42, avg 1µs/call # 9 times (13µs+0s) by Class::XSAccessor::import at line 43, avg 1µs/call
sub _make_hash {
147216µs my $ref = shift;
15
167228µs if (ref ($ref)) {
17 if (ref($ref) eq 'ARRAY') {
18 $ref = { map { $_ => $_ } @$ref }
19 }
20 } else {
21 $ref = { $ref, $ref };
22 }
23
2472150µs return $ref;
25}
26
27
# spent 860µs (567+293) within Class::XSAccessor::import which was called 9 times, avg 96µs/call: # 9 times (567µs+293µs) by Method::Generate::Accessor::_generate_xs at line 614 of Method/Generate/Accessor.pm, avg 96µs/call
sub import {
2894µs my $own_class = shift;
29916µs my ($caller_pkg) = caller();
30
31 # Support both { getters => ... } and plain getters => ...
32918µs my %opts = ref($_[0]) eq 'HASH' ? %{$_[0]} : @_;
33
3497µs $caller_pkg = $opts{class} if defined $opts{class};
35
36 # TODO: Refactor. Move more duplicated code to ::Heavy
37914µs920µs my $read_subs = _make_hash($opts{getters} || {});
# spent 20µs making 9 calls to Class::XSAccessor::_make_hash, avg 2µs/call
38914µs914µs my $set_subs = _make_hash($opts{setters} || {});
# spent 14µs making 9 calls to Class::XSAccessor::_make_hash, avg 2µs/call
39913µs913µs my $acc_subs = _make_hash($opts{accessors} || {});
# spent 13µs making 9 calls to Class::XSAccessor::_make_hash, avg 1µs/call
40912µs913µs my $lvacc_subs = _make_hash($opts{lvalue_accessors} || {});
# spent 13µs making 9 calls to Class::XSAccessor::_make_hash, avg 1µs/call
41912µs913µs my $pred_subs = _make_hash($opts{predicates} || {});
# spent 13µs making 9 calls to Class::XSAccessor::_make_hash, avg 1µs/call
42911µs913µs my $ex_pred_subs = _make_hash($opts{exists_predicates} || {});
# spent 13µs making 9 calls to Class::XSAccessor::_make_hash, avg 1µs/call
43912µs913µs my $def_pred_subs = _make_hash($opts{defined_predicates} || {});
# spent 13µs making 9 calls to Class::XSAccessor::_make_hash, avg 1µs/call
44919µs913µs my $test_subs = _make_hash($opts{__tests__} || {});
# spent 13µs making 9 calls to Class::XSAccessor::_make_hash, avg 1µs/call
4597µs my $construct_subs = $opts{constructors} || [defined($opts{constructor}) ? $opts{constructor} : ()];
4694µs my $true_subs = $opts{true} || [];
4793µs my $false_subs = $opts{false} || [];
48
49943µ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 {
587227µs my $subs = $subtype->[1];
5972135µs foreach my $subname (keys %$subs) {
6094µs my $hashkey = $subs->{$subname};
61939µs9181µs _generate_method($caller_pkg, $subname, $hashkey, \%opts, $subtype->[0]);
# spent 181µs making 9 calls to Class::XSAccessor::_generate_method, avg 20µs/call
62 }
63 }
64
65960µs foreach my $subtype ( ["constructor", $construct_subs],
66 ["true", $true_subs],
67 ["false", $false_subs] )
68 {
692723µs foreach my $subname (@{$subtype->[1]}) {
70 _generate_method($caller_pkg, $subname, "", \%opts, $subtype->[0]);
71 }
72 }
73}
74
75
# spent 181µs (101+80) within Class::XSAccessor::_generate_method which was called 9 times, avg 20µs/call: # 9 times (101µs+80µs) by Class::XSAccessor::import at line 61, avg 20µs/call
sub _generate_method {
7696µs my ($caller_pkg, $subname, $hashkey, $opts, $type) = @_;
77
7893µs croak("Cannot use undef as a hash key for generating an XS $type accessor. (Sub: $subname)")
79 if not defined $hashkey;
80
81943µs98µs $subname = "${caller_pkg}::$subname" if $subname !~ /::/;
# spent 8µs making 9 calls to Class::XSAccessor::CORE:match, avg 889ns/call
82
8394µs Class::XSAccessor::Heavy::check_sub_existence($subname) if not $opts->{replace};
842235µs240µs
# spent 27µs (13+14) within Class::XSAccessor::BEGIN@84 which was called: # once (13µs+14µs) by Module::Runtime::require_module at line 84
no warnings 'redefine'; # don't warn about an explicitly requested redefine
# spent 27µs making 1 call to Class::XSAccessor::BEGIN@84 # spent 14µs making 1 call to warnings::unimport
85
86971µs530µs if ($type eq 'getter') {
# spent 30µs making 5 calls to Class::XSAccessor::newxs_getter, avg 6µs/call
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 {
114462µs442µs newxs_accessor($subname, $hashkey, $opts->{chained}||0);
# spent 42µs making 4 calls to Class::XSAccessor::newxs_accessor, avg 10µs/call
115 }
116}
117
11815µs1;
119
120__END__
 
# spent 8µs within Class::XSAccessor::CORE:match which was called 9 times, avg 889ns/call: # 9 times (8µs+0s) by Class::XSAccessor::_generate_method at line 81, avg 889ns/call
sub Class::XSAccessor::CORE:match; # opcode
# spent 4µs within Class::XSAccessor::END which was called: # once (4µs+0s) by main::RUNTIME at line 0 of index.cgi
sub Class::XSAccessor::END; # xsub
# spent 42µs within Class::XSAccessor::newxs_accessor which was called 4 times, avg 10µs/call: # 4 times (42µs+0s) by Class::XSAccessor::_generate_method at line 114, avg 10µs/call
sub Class::XSAccessor::newxs_accessor; # xsub
# spent 30µs within Class::XSAccessor::newxs_getter which was called 5 times, avg 6µs/call: # 5 times (30µs+0s) by Class::XSAccessor::_generate_method at line 86, avg 6µs/call
sub Class::XSAccessor::newxs_getter; # xsub