Filename | /usr/lib/x86_64-linux-gnu/perl5/5.20/Class/XSAccessor.pm |
Statements | Executed 68 statements in 157µs |
Calls | P | F | Exclusive Time |
Inclusive Time |
Subroutine |
---|---|---|---|---|---|
33 | 1 | 1 | 3.92ms | 4.23ms | _generate_method | Class::XSAccessor::
33 | 2 | 2 | 1.53ms | 6.06ms | import | Class::XSAccessor::
1 | 1 | 1 | 410µs | 518µs | BEGIN@6 | Class::XSAccessor::
264 | 8 | 1 | 297µs | 297µs | _make_hash | Class::XSAccessor::
29 | 1 | 1 | 245µs | 245µs | newxs_accessor (xsub) | Class::XSAccessor::
33 | 1 | 1 | 38µs | 38µs | CORE:match (opcode) | Class::XSAccessor::
4 | 1 | 1 | 24µs | 24µs | newxs_getter (xsub) | Class::XSAccessor::
1 | 1 | 1 | 19µs | 19µs | BEGIN@2 | Class::XSAccessor::
1 | 1 | 1 | 12µs | 24µs | BEGIN@84 | Class::XSAccessor::
1 | 1 | 1 | 11µs | 15µs | BEGIN@4 | Class::XSAccessor::
1 | 1 | 1 | 9µs | 43µs | BEGIN@5 | Class::XSAccessor::
1 | 1 | 1 | 8µs | 15µs | BEGIN@3 | 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 | 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 | 22µs | # spent 15µs (8+7) within Class::XSAccessor::BEGIN@3 which was called:
# once (8µs+7µs) by Module::Runtime::require_module at line 3 # spent 15µs making 1 call to Class::XSAccessor::BEGIN@3
# spent 7µs making 1 call to strict::import | ||
4 | 2 | 18µs | # spent 15µs (11+4) within Class::XSAccessor::BEGIN@4 which was called:
# once (11µs+4µs) by Module::Runtime::require_module at line 4 # spent 15µs making 1 call to Class::XSAccessor::BEGIN@4
# spent 4µs making 1 call to warnings::import | ||
5 | 2 | 76µs | # spent 43µs (9+33) within Class::XSAccessor::BEGIN@5 which was called:
# once (9µs+33µs) by Module::Runtime::require_module at line 5 # spent 43µs making 1 call to Class::XSAccessor::BEGIN@5
# spent 33µs making 1 call to Exporter::import | ||
6 | 1 | 518µs | # spent 518µs (410+109) within Class::XSAccessor::BEGIN@6 which was called:
# once (410µs+109µs) by Module::Runtime::require_module at line 6 # spent 518µs making 1 call to Class::XSAccessor::BEGIN@6 | ||
7 | 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 | our $VERSION = '1.19'; | ||||
10 | |||||
11 | 1 | 332µs | XSLoader::load('Class::XSAccessor', $VERSION); # spent 332µs making 1 call to XSLoader::load | ||
12 | |||||
13 | # spent 297µs within Class::XSAccessor::_make_hash which was called 264 times, avg 1µs/call:
# 33 times (102µs+0s) by Class::XSAccessor::import at line 37, avg 3µs/call
# 33 times (37µs+0s) by Class::XSAccessor::import at line 43, avg 1µs/call
# 33 times (29µs+0s) by Class::XSAccessor::import at line 38, avg 870ns/call
# 33 times (27µs+0s) by Class::XSAccessor::import at line 39, avg 818ns/call
# 33 times (27µs+0s) by Class::XSAccessor::import at line 42, avg 806ns/call
# 33 times (25µs+0s) by Class::XSAccessor::import at line 40, avg 767ns/call
# 33 times (25µs+0s) by Class::XSAccessor::import at line 41, avg 764ns/call
# 33 times (25µs+0s) by Class::XSAccessor::import at line 44, avg 755ns/call | ||||
14 | 8 | 1µs | my $ref = shift; | ||
15 | |||||
16 | 8 | 34µs | if (ref ($ref)) { | ||
17 | if (ref($ref) eq 'ARRAY') { | ||||
18 | $ref = { map { $_ => $_ } @$ref } | ||||
19 | } | ||||
20 | } else { | ||||
21 | $ref = { $ref, $ref }; | ||||
22 | } | ||||
23 | |||||
24 | 8 | 25µs | return $ref; | ||
25 | } | ||||
26 | |||||
27 | # spent 6.06ms (1.53+4.52) within Class::XSAccessor::import which was called 33 times, avg 184µs/call:
# 29 times (1.36ms+800µs) 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::SQLMaker::limit_dialect or DBIx::Class::SQLMaker::name_sep or DBIx::Class::Storage::DBI::Cursor::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 75µs/call
# 4 times (170µs+3.72ms) by Method::Generate::Accessor::_generate_xs at line 641 of Method/Generate/Accessor.pm, avg 974µs/call | ||||
28 | 1 | 2µs | my $own_class = shift; | ||
29 | 1 | 2µs | my ($caller_pkg) = caller(); | ||
30 | |||||
31 | # Support both { getters => ... } and plain getters => ... | ||||
32 | 1 | 7µs | my %opts = ref($_[0]) eq 'HASH' ? %{$_[0]} : @_; | ||
33 | |||||
34 | 1 | 2µs | $caller_pkg = $opts{class} if defined $opts{class}; | ||
35 | |||||
36 | # TODO: Refactor. Move more duplicated code to ::Heavy | ||||
37 | 1 | 4µs | 33 | 102µs | my $read_subs = _make_hash($opts{getters} || {}); # spent 102µs making 33 calls to Class::XSAccessor::_make_hash, avg 3µs/call |
38 | 1 | 3µs | 33 | 29µs | my $set_subs = _make_hash($opts{setters} || {}); # spent 29µs making 33 calls to Class::XSAccessor::_make_hash, avg 870ns/call |
39 | 1 | 1µs | 33 | 27µs | my $acc_subs = _make_hash($opts{accessors} || {}); # spent 27µs making 33 calls to Class::XSAccessor::_make_hash, avg 818ns/call |
40 | 1 | 1µs | 33 | 25µs | my $lvacc_subs = _make_hash($opts{lvalue_accessors} || {}); # spent 25µs making 33 calls to Class::XSAccessor::_make_hash, avg 767ns/call |
41 | 1 | 2µs | 33 | 25µs | my $pred_subs = _make_hash($opts{predicates} || {}); # spent 25µs making 33 calls to Class::XSAccessor::_make_hash, avg 764ns/call |
42 | 1 | 1µs | 33 | 27µs | my $ex_pred_subs = _make_hash($opts{exists_predicates} || {}); # spent 27µs making 33 calls to Class::XSAccessor::_make_hash, avg 806ns/call |
43 | 1 | 900ns | 33 | 37µs | my $def_pred_subs = _make_hash($opts{defined_predicates} || {}); # spent 37µs making 33 calls to Class::XSAccessor::_make_hash, avg 1µs/call |
44 | 1 | 1µs | 33 | 25µs | my $test_subs = _make_hash($opts{__tests__} || {}); # spent 25µs making 33 calls to Class::XSAccessor::_make_hash, avg 755ns/call |
45 | 1 | 900ns | my $construct_subs = $opts{constructors} || [defined($opts{constructor}) ? $opts{constructor} : ()]; | ||
46 | 1 | 500ns | my $true_subs = $opts{true} || []; | ||
47 | 1 | 500ns | my $false_subs = $opts{false} || []; | ||
48 | |||||
49 | 1 | 9µ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 | 8 | 2µs | my $subs = $subtype->[1]; | ||
59 | 8 | 9µs | foreach my $subname (keys %$subs) { | ||
60 | 1 | 2µs | my $hashkey = $subs->{$subname}; | ||
61 | 1 | 4µs | 33 | 4.23ms | _generate_method($caller_pkg, $subname, $hashkey, \%opts, $subtype->[0]); # spent 4.23ms making 33 calls to Class::XSAccessor::_generate_method, avg 128µs/call |
62 | } | ||||
63 | } | ||||
64 | |||||
65 | 1 | 9µs | foreach my $subtype ( ["constructor", $construct_subs], | ||
66 | ["true", $true_subs], | ||||
67 | ["false", $false_subs] ) | ||||
68 | { | ||||
69 | 3 | 2µs | foreach my $subname (@{$subtype->[1]}) { | ||
70 | _generate_method($caller_pkg, $subname, "", \%opts, $subtype->[0]); | ||||
71 | } | ||||
72 | } | ||||
73 | } | ||||
74 | |||||
75 | # spent 4.23ms (3.92+307µs) within Class::XSAccessor::_generate_method which was called 33 times, avg 128µs/call:
# 33 times (3.92ms+307µs) by Class::XSAccessor::import at line 61, avg 128µs/call | ||||
76 | 1 | 900ns | my ($caller_pkg, $subname, $hashkey, $opts, $type) = @_; | ||
77 | |||||
78 | 1 | 300ns | croak("Cannot use undef as a hash key for generating an XS $type accessor. (Sub: $subname)") | ||
79 | if not defined $hashkey; | ||||
80 | |||||
81 | 1 | 7µs | 33 | 38µs | $subname = "${caller_pkg}::$subname" if $subname !~ /::/; # spent 38µs making 33 calls to Class::XSAccessor::CORE:match, avg 1µs/call |
82 | |||||
83 | 1 | 500ns | Class::XSAccessor::Heavy::check_sub_existence($subname) if not $opts->{replace}; | ||
84 | 2 | 36µs | # spent 24µs (12+12) within Class::XSAccessor::BEGIN@84 which was called:
# once (12µs+12µs) by Module::Runtime::require_module at line 84 # spent 24µs making 1 call to Class::XSAccessor::BEGIN@84
# spent 12µs making 1 call to warnings::unimport | ||
85 | |||||
86 | 1 | 4µs | 4 | 24µs | if ($type eq 'getter') { # spent 24µs making 4 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 { | ||||
114 | 1 | 20µs | 29 | 245µs | newxs_accessor($subname, $hashkey, $opts->{chained}||0); # spent 245µs making 29 calls to Class::XSAccessor::newxs_accessor, avg 8µs/call |
115 | } | ||||
116 | } | ||||
117 | |||||
118 | 1; | ||||
119 | |||||
120 | __END__ | ||||
# spent 38µs within Class::XSAccessor::CORE:match which was called 33 times, avg 1µs/call:
# 33 times (38µs+0s) by Class::XSAccessor::_generate_method at line 81, avg 1µs/call | |||||
# spent 245µs within Class::XSAccessor::newxs_accessor which was called 29 times, avg 8µs/call:
# 29 times (245µs+0s) by Class::XSAccessor::_generate_method at line 114, avg 8µs/call | |||||
# spent 24µs within Class::XSAccessor::newxs_getter which was called 4 times, avg 6µs/call:
# 4 times (24µs+0s) by Class::XSAccessor::_generate_method at line 86, avg 6µs/call |