Filename | /usr/lib/x86_64-linux-gnu/perl5/5.20/Class/XSAccessor.pm |
Statements | Executed 2053 statements in 4.38ms |
Calls | P | F | Exclusive Time |
Inclusive Time |
Subroutine |
---|---|---|---|---|---|
30 | 2 | 2 | 1.38ms | 2.82ms | import | Class::XSAccessor::
240 | 8 | 1 | 938µs | 938µs | _make_hash | Class::XSAccessor::
1 | 1 | 1 | 389µs | 494µs | BEGIN@6 | Class::XSAccessor::
30 | 1 | 1 | 260µs | 506µs | _generate_method | Class::XSAccessor::
26 | 1 | 1 | 192µs | 192µs | newxs_accessor (xsub) | Class::XSAccessor::
30 | 1 | 1 | 32µs | 32µs | CORE:match (opcode) | Class::XSAccessor::
4 | 1 | 1 | 22µs | 22µs | newxs_getter (xsub) | Class::XSAccessor::
1 | 1 | 1 | 19µs | 19µs | BEGIN@2 | Class::XSAccessor::
1 | 1 | 1 | 10µs | 17µs | BEGIN@3 | Class::XSAccessor::
1 | 1 | 1 | 9µs | 37µs | BEGIN@5 | Class::XSAccessor::
1 | 1 | 1 | 9µs | 18µs | BEGIN@84 | Class::XSAccessor::
1 | 1 | 1 | 8µs | 12µs | BEGIN@4 | Class::XSAccessor::
1 | 1 | 1 | 7µs | 7µs | BEGIN@7 | Class::XSAccessor::
Line | State ments |
Time on line |
Calls | Time in subs |
Code |
---|---|---|---|---|---|
1 | package Class::XSAccessor; | ||||
2 | 2 | 48µs | 1 | 19µs | # spent 19µs within Class::XSAccessor::BEGIN@2 which was called:
# once (19µs+0s) by Module::Runtime::require_module at line 2 # spent 19µs making 1 call to Class::XSAccessor::BEGIN@2 |
3 | 2 | 35µs | 2 | 24µs | # spent 17µs (10+7) within Class::XSAccessor::BEGIN@3 which was called:
# once (10µs+7µs) by Module::Runtime::require_module at line 3 # spent 17µs making 1 call to Class::XSAccessor::BEGIN@3
# spent 7µs making 1 call to strict::import |
4 | 2 | 29µs | 2 | 16µs | # spent 12µs (8+4) within Class::XSAccessor::BEGIN@4 which was called:
# once (8µs+4µs) by Module::Runtime::require_module at line 4 # spent 12µs making 1 call to Class::XSAccessor::BEGIN@4
# spent 4µs making 1 call to warnings::import |
5 | 2 | 59µs | 2 | 65µs | # spent 37µs (9+28) within Class::XSAccessor::BEGIN@5 which was called:
# once (9µs+28µs) by Module::Runtime::require_module at line 5 # spent 37µs making 1 call to Class::XSAccessor::BEGIN@5
# spent 28µs making 1 call to Exporter::import |
6 | 2 | 126µs | 1 | 494µs | # spent 494µs (389+104) within Class::XSAccessor::BEGIN@6 which was called:
# once (389µs+104µs) by Module::Runtime::require_module at line 6 # spent 494µs making 1 call to Class::XSAccessor::BEGIN@6 |
7 | 2 | 436µs | 1 | 7µs | # spent 7µs within Class::XSAccessor::BEGIN@7 which was called:
# once (7µs+0s) by Module::Runtime::require_module at line 7 # spent 7µs making 1 call to Class::XSAccessor::BEGIN@7 |
8 | |||||
9 | 1 | 400ns | our $VERSION = '1.19'; | ||
10 | |||||
11 | 1 | 575µs | 1 | 563µs | XSLoader::load('Class::XSAccessor', $VERSION); # spent 563µs making 1 call to XSLoader::load |
12 | |||||
13 | # spent 938µs within Class::XSAccessor::_make_hash which was called 240 times, avg 4µs/call:
# 30 times (721µs+0s) by Class::XSAccessor::import at line 37, avg 24µs/call
# 30 times (57µs+0s) by Class::XSAccessor::import at line 38, avg 2µs/call
# 30 times (33µs+0s) by Class::XSAccessor::import at line 39, avg 1µs/call
# 30 times (27µs+0s) by Class::XSAccessor::import at line 40, avg 910ns/call
# 30 times (27µs+0s) by Class::XSAccessor::import at line 41, avg 903ns/call
# 30 times (25µs+0s) by Class::XSAccessor::import at line 42, avg 847ns/call
# 30 times (25µs+0s) by Class::XSAccessor::import at line 44, avg 820ns/call
# 30 times (23µs+0s) by Class::XSAccessor::import at line 43, avg 757ns/call | ||||
14 | 240 | 60µs | my $ref = shift; | ||
15 | |||||
16 | 240 | 89µs | if (ref ($ref)) { | ||
17 | if (ref($ref) eq 'ARRAY') { | ||||
18 | $ref = { map { $_ => $_ } @$ref } | ||||
19 | } | ||||
20 | } else { | ||||
21 | $ref = { $ref, $ref }; | ||||
22 | } | ||||
23 | |||||
24 | 240 | 379µs | return $ref; | ||
25 | } | ||||
26 | |||||
27 | # spent 2.82ms (1.38+1.44) within Class::XSAccessor::import which was called 30 times, avg 94µs/call:
# 26 times (1.16ms+1.35ms) by DBIx::Class::ResultSet::_result_class or DBIx::Class::ResultSet::result_source or DBIx::Class::ResultSource::_columns or DBIx::Class::ResultSource::_ordered_columns or DBIx::Class::ResultSource::_primaries or DBIx::Class::ResultSource::_relationships or DBIx::Class::ResultSource::_unique_constraints or DBIx::Class::ResultSource::name or DBIx::Class::ResultSource::source_name or DBIx::Class::Row::in_storage or DBIx::Class::Storage::DBI::_conn_pid or DBIx::Class::Storage::DBI::_connect_info or DBIx::Class::Storage::DBI::_dbh or DBIx::Class::Storage::DBI::_dbh_autocommit or DBIx::Class::Storage::DBI::_dbh_details or DBIx::Class::Storage::DBI::_dbic_connect_attributes or DBIx::Class::Storage::DBI::_driver_determined or DBIx::Class::Storage::DBI::_sql_maker or DBIx::Class::Storage::DBI::_sql_maker_opts or DBIx::Class::Storage::DBI::disable_sth_caching or DBIx::Class::Storage::DBI::on_connect_call or DBIx::Class::Storage::DBI::on_connect_do or DBIx::Class::Storage::DBI::unsafe or DBIx::Class::Storage::debug or DBIx::Class::Storage::schema or DBIx::Class::Storage::transaction_depth at line 830 of Class/Accessor/Grouped.pm, avg 96µs/call
# 4 times (221µs+94µs) by Method::Generate::Accessor::_generate_xs at line 641 of Method/Generate/Accessor.pm, avg 79µs/call | ||||
28 | 30 | 12µs | my $own_class = shift; | ||
29 | 30 | 37µs | my ($caller_pkg) = caller(); | ||
30 | |||||
31 | # Support both { getters => ... } and plain getters => ... | ||||
32 | 30 | 78µs | my %opts = ref($_[0]) eq 'HASH' ? %{$_[0]} : @_; | ||
33 | |||||
34 | 30 | 21µs | $caller_pkg = $opts{class} if defined $opts{class}; | ||
35 | |||||
36 | # TODO: Refactor. Move more duplicated code to ::Heavy | ||||
37 | 30 | 673µs | 30 | 721µs | my $read_subs = _make_hash($opts{getters} || {}); # spent 721µs making 30 calls to Class::XSAccessor::_make_hash, avg 24µs/call |
38 | 30 | 60µs | 30 | 57µs | my $set_subs = _make_hash($opts{setters} || {}); # spent 57µs making 30 calls to Class::XSAccessor::_make_hash, avg 2µs/call |
39 | 30 | 35µs | 30 | 33µs | my $acc_subs = _make_hash($opts{accessors} || {}); # spent 33µs making 30 calls to Class::XSAccessor::_make_hash, avg 1µs/call |
40 | 30 | 32µs | 30 | 27µs | my $lvacc_subs = _make_hash($opts{lvalue_accessors} || {}); # spent 27µs making 30 calls to Class::XSAccessor::_make_hash, avg 910ns/call |
41 | 30 | 31µs | 30 | 27µs | my $pred_subs = _make_hash($opts{predicates} || {}); # spent 27µs making 30 calls to Class::XSAccessor::_make_hash, avg 903ns/call |
42 | 30 | 28µs | 30 | 25µs | my $ex_pred_subs = _make_hash($opts{exists_predicates} || {}); # spent 25µs making 30 calls to Class::XSAccessor::_make_hash, avg 847ns/call |
43 | 30 | 28µs | 30 | 23µs | my $def_pred_subs = _make_hash($opts{defined_predicates} || {}); # spent 23µs making 30 calls to Class::XSAccessor::_make_hash, avg 757ns/call |
44 | 30 | 26µs | 30 | 25µs | my $test_subs = _make_hash($opts{__tests__} || {}); # spent 25µs making 30 calls to Class::XSAccessor::_make_hash, avg 820ns/call |
45 | 30 | 24µs | my $construct_subs = $opts{constructors} || [defined($opts{constructor}) ? $opts{constructor} : ()]; | ||
46 | 30 | 10µs | my $true_subs = $opts{true} || []; | ||
47 | 30 | 15µs | my $false_subs = $opts{false} || []; | ||
48 | |||||
49 | 30 | 115µ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 | { | ||||
58 | 240 | 45µs | my $subs = $subtype->[1]; | ||
59 | 240 | 224µs | foreach my $subname (keys %$subs) { | ||
60 | 30 | 10µs | my $hashkey = $subs->{$subname}; | ||
61 | 30 | 68µs | 30 | 506µs | _generate_method($caller_pkg, $subname, $hashkey, \%opts, $subtype->[0]); # spent 506µs making 30 calls to Class::XSAccessor::_generate_method, avg 17µs/call |
62 | } | ||||
63 | } | ||||
64 | |||||
65 | 30 | 208µs | foreach my $subtype ( ["constructor", $construct_subs], | ||
66 | ["true", $true_subs], | ||||
67 | ["false", $false_subs] ) | ||||
68 | { | ||||
69 | 90 | 51µs | foreach my $subname (@{$subtype->[1]}) { | ||
70 | _generate_method($caller_pkg, $subname, "", \%opts, $subtype->[0]); | ||||
71 | } | ||||
72 | } | ||||
73 | } | ||||
74 | |||||
75 | # spent 506µs (260+245) within Class::XSAccessor::_generate_method which was called 30 times, avg 17µs/call:
# 30 times (260µs+245µs) by Class::XSAccessor::import at line 61, avg 17µs/call | ||||
76 | 30 | 18µs | my ($caller_pkg, $subname, $hashkey, $opts, $type) = @_; | ||
77 | |||||
78 | 30 | 5µs | croak("Cannot use undef as a hash key for generating an XS $type accessor. (Sub: $subname)") | ||
79 | if not defined $hashkey; | ||||
80 | |||||
81 | 30 | 119µs | 30 | 32µs | $subname = "${caller_pkg}::$subname" if $subname !~ /::/; # spent 32µs making 30 calls to Class::XSAccessor::CORE:match, avg 1µs/call |
82 | |||||
83 | 30 | 12µs | Class::XSAccessor::Heavy::check_sub_existence($subname) if not $opts->{replace}; | ||
84 | 2 | 192µs | 2 | 28µs | # spent 18µs (9+10) within Class::XSAccessor::BEGIN@84 which was called:
# once (9µs+10µs) by Module::Runtime::require_module at line 84 # spent 18µs making 1 call to Class::XSAccessor::BEGIN@84
# spent 10µs making 1 call to warnings::unimport |
85 | |||||
86 | 30 | 112µs | 4 | 22µs | if ($type eq 'getter') { # spent 22µs making 4 calls to Class::XSAccessor::newxs_getter, avg 5µ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 { | ||||
114 | 26 | 252µs | 26 | 192µs | newxs_accessor($subname, $hashkey, $opts->{chained}||0); # spent 192µs making 26 calls to Class::XSAccessor::newxs_accessor, avg 7µs/call |
115 | } | ||||
116 | } | ||||
117 | |||||
118 | 1 | 5µs | 1; | ||
119 | |||||
120 | __END__ | ||||
# spent 32µs within Class::XSAccessor::CORE:match which was called 30 times, avg 1µs/call:
# 30 times (32µs+0s) by Class::XSAccessor::_generate_method at line 81, avg 1µs/call | |||||
# spent 192µs within Class::XSAccessor::newxs_accessor which was called 26 times, avg 7µs/call:
# 26 times (192µs+0s) by Class::XSAccessor::_generate_method at line 114, avg 7µs/call | |||||
# spent 22µs within Class::XSAccessor::newxs_getter which was called 4 times, avg 5µs/call:
# 4 times (22µs+0s) by Class::XSAccessor::_generate_method at line 86, avg 5µs/call |