Profile of Class/XSAccessor.pm

← Index
NYTProf Performance Profile «block view•line view•sub view»
For xt/tapper-mcp-scheduler-with-db-longrun.t
Run on Tue May 22 17:18:39 2012
Reported on Tue May 22 17:22:36 2012

Filename | /2home/ss5/perl5/perlbrew/perls/perl-5.12.3/lib/site_perl/5.12.3/x86_64-linux/Class/XSAccessor.pm
Statements | Executed 2040 statements in 4.48ms

Subroutines
Calls | P | F | Exclusive Time | Inclusive Time | Subroutine
--- | --- | --- | --- | --- | ---
36 | 1 | 1 | 1.74ms | 3.36ms | Class::XSAccessor::::importClass::XSAccessor::import
36 | 1 | 1 | 861µs | 861µs | Class::XSAccessor::::newxs_accessorClass::XSAccessor::newxs_accessor (xsub)
36 | 1 | 1 | 381µs | 1.28ms | Class::XSAccessor::::_generate_methodClass::XSAccessor::_generate_method
216 | 6 | 1 | 341µs | 341µs | Class::XSAccessor::::_make_hashClass::XSAccessor::_make_hash
1 | 1 | 1 | 265µs | 383µs | Class::XSAccessor::::BEGIN@6Class::XSAccessor::BEGIN@6
36 | 1 | 1 | 36µs | 36µs | Class::XSAccessor::::CORE:matchClass::XSAccessor::CORE:match (opcode)
1 | 1 | 1 | 34µs | 34µs | Class::XSAccessor::::BEGIN@2Class::XSAccessor::BEGIN@2
1 | 1 | 1 | 14µs | 14µs | Class::XSAccessor::::ENDClass::XSAccessor::END (xsub)
1 | 1 | 1 | 9µs | 56µs | Class::XSAccessor::::BEGIN@5Class::XSAccessor::BEGIN@5
1 | 1 | 1 | 8µs | 18µs | Class::XSAccessor::::BEGIN@80Class::XSAccessor::BEGIN@80
1 | 1 | 1 | 7µs | 18µs | Class::XSAccessor::::BEGIN@4Class::XSAccessor::BEGIN@4
1 | 1 | 1 | 7µs | 10µs | Class::XSAccessor::::BEGIN@3Class::XSAccessor::BEGIN@3
1 | 1 | 1 | 6µs | 6µs | Class::XSAccessor::::BEGIN@7Class::XSAccessor::BEGIN@7

Call graph for these subroutines as a Graphviz dot language file.

Line | State ments | Time on line | Calls | Time in subs | Code
--- | --- | --- | --- | --- | ---
1 |  |  |  |  | package Class::XSAccessor;
2 | 3 | 43µs | 1 | 34µs | # spent 34µs within Class::XSAccessor::BEGIN@2 which was called: # once (34µs+0s) by Class::Accessor::Grouped::BEGIN@529 at line 2 use 5.008; # spent 34µs making 1 call to Class::XSAccessor::BEGIN@2
3 | 3 | 17µs | 2 | 14µs | # spent 10µs (7+4) within Class::XSAccessor::BEGIN@3 which was called: # once (7µs+4µs) by Class::Accessor::Grouped::BEGIN@529 at line 3 use strict; # spent 10µs making 1 call to Class::XSAccessor::BEGIN@3 # spent 3µs making 1 call to strict::import
4 | 3 | 20µs | 2 | 30µs | # spent 18µs (7+12) within Class::XSAccessor::BEGIN@4 which was called: # once (7µs+12µs) by Class::Accessor::Grouped::BEGIN@529 at line 4 use warnings; # spent 18µs making 1 call to Class::XSAccessor::BEGIN@4 # spent 12µs making 1 call to warnings::import
5 | 3 | 21µs | 2 | 103µs | # spent 56µs (9+47) within Class::XSAccessor::BEGIN@5 which was called: # once (9µs+47µs) by Class::Accessor::Grouped::BEGIN@529 at line 5 use Carp qw/croak/; # spent 56µs making 1 call to Class::XSAccessor::BEGIN@5 # spent 47µs making 1 call to Exporter::import
6 | 3 | 75µs | 1 | 383µs | # spent 383µs (265+117) within Class::XSAccessor::BEGIN@6 which was called: # once (265µs+117µs) by Class::Accessor::Grouped::BEGIN@529 at line 6 use Class::XSAccessor::Heavy; # spent 383µs making 1 call to Class::XSAccessor::BEGIN@6
7 | 3 | 340µs | 1 | 6µs | # spent 6µs within Class::XSAccessor::BEGIN@7 which was called: # once (6µs+0s) by Class::Accessor::Grouped::BEGIN@529 at line 7 use XSLoader; # spent 6µs making 1 call to Class::XSAccessor::BEGIN@7
8 |  |  |  |  |
9 | 1 | 600ns |  |  | our $VERSION = '1.13';
10 |  |  |  |  |
11 | 1 | 368µs | 1 | 358µs | XSLoader::load('Class::XSAccessor', $VERSION); # spent 358µs making 1 call to XSLoader::load
12 |  |  |  |  |
13 |  |  |  |  | # spent 341µs within Class::XSAccessor::_make_hash which was called 216 times, avg 2µs/call: # 36 times (104µs+0s) by Class::XSAccessor::import at line 37, avg 3µs/call # 36 times (50µs+0s) by Class::XSAccessor::import at line 38, avg 1µs/call # 36 times (47µs+0s) by Class::XSAccessor::import at line 39, avg 1µs/call # 36 times (47µs+0s) by Class::XSAccessor::import at line 42, avg 1µs/call # 36 times (46µs+0s) by Class::XSAccessor::import at line 41, avg 1µs/call # 36 times (46µs+0s) by Class::XSAccessor::import at line 40, avg 1µs/call sub _make_hash {
14 | 648 | 529µs |  |  | my $ref = shift;
15 |  |  |  |  |
16 |  |  |  |  | if (ref ($ref)) {
17 |  |  |  |  | if (ref($ref) eq 'ARRAY') {
18 |  |  |  |  | $ref = { map { $_ => $_ } @$ref }
19 |  |  |  |  | }
20 |  |  |  |  | } else {
21 |  |  |  |  | $ref = { $ref, $ref };
22 |  |  |  |  | }
23 |  |  |  |  |
24 |  |  |  |  | return $ref;
25 |  |  |  |  | }
26 |  |  |  |  |
27 |  |  |  |  | # spent 3.36ms (1.74+1.62) within Class::XSAccessor::import which was called 36 times, avg 93µs/call: # 36 times (1.74ms+1.62ms) by DBIx::Class::ResultSet::_result_class or DBIx::Class::ResultSet::result_source or DBIx::Class::ResultSource::View::is_virtual or DBIx::Class::ResultSource::View::view_definition 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::resultset_attributes or DBIx::Class::ResultSource::source_name or DBIx::Class::SQLMaker::limit_dialect or DBIx::Class::SQLMaker::name_sep or DBIx::Class::Storage::DBI::Cursor::sth 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::_dbi_connect_info 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 699 of Class/Accessor/Grouped.pm, avg 93µs/call sub import {
28 | 1152 | 1.61ms |  |  | my $own_class = shift;
29 |  |  |  |  | my ($caller_pkg) = caller();
30 |  |  |  |  |
31 |  |  |  |  | # Support both { getters => ... } and plain getters => ...
32 |  |  |  |  | my %opts = ref($_[0]) eq 'HASH' ? %{$_[0]} : @_;
33 |  |  |  |  |
34 |  |  |  |  | $caller_pkg = $opts{class} if defined $opts{class};
35 |  |  |  |  |
36 |  |  |  |  | # TODO: Refactor. Move more duplicated code to ::Heavy
37 |  |  | 36 | 104µs | my $read_subs = _make_hash($opts{getters} || {}); # spent 104µs making 36 calls to Class::XSAccessor::_make_hash, avg 3µs/call
38 |  |  | 36 | 50µs | my $set_subs = _make_hash($opts{setters} || {}); # spent 50µs making 36 calls to Class::XSAccessor::_make_hash, avg 1µs/call
39 |  |  | 36 | 47µs | my $acc_subs = _make_hash($opts{accessors} || {}); # spent 47µs making 36 calls to Class::XSAccessor::_make_hash, avg 1µs/call
40 |  |  | 36 | 46µs | my $lvacc_subs = _make_hash($opts{lvalue_accessors} || {}); # spent 46µs making 36 calls to Class::XSAccessor::_make_hash, avg 1µs/call
41 |  |  | 36 | 46µs | my $pred_subs = _make_hash($opts{predicates} || {}); # spent 46µs making 36 calls to Class::XSAccessor::_make_hash, avg 1µs/call
42 |  |  | 36 | 47µs | my $test_subs = _make_hash($opts{__tests__} || {}); # spent 47µs making 36 calls to Class::XSAccessor::_make_hash, avg 1µs/call
43 |  |  |  |  | my $construct_subs = $opts{constructors} || [defined($opts{constructor}) ? $opts{constructor} : ()];
44 |  |  |  |  | my $true_subs = $opts{true} || [];
45 |  |  |  |  | my $false_subs = $opts{false} || [];
46 |  |  |  |  |
47 |  |  |  |  | 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 |  |  |  |  | {
54 |  |  |  |  | my $subs = $subtype->[1];
55 |  |  |  |  | foreach my $subname (keys %$subs) {
56 |  |  |  |  | my $hashkey = $subs->{$subname};
57 |  |  | 36 | 1.28ms | _generate_method($caller_pkg, $subname, $hashkey, \%opts, $subtype->[0]); # spent 1.28ms making 36 calls to Class::XSAccessor::_generate_method, avg 35µs/call
58 |  |  |  |  | }
59 |  |  |  |  | }
60 |  |  |  |  |
61 |  |  |  |  | foreach my $subtype ( ["constructor", $construct_subs],
62 |  |  |  |  | ["true", $true_subs],
63 |  |  |  |  | ["false", $false_subs] )
64 |  |  |  |  | {
65 |  |  |  |  | foreach my $subname (@{$subtype->[1]}) {
66 |  |  |  |  | _generate_method($caller_pkg, $subname, "", \%opts, $subtype->[0]);
67 |  |  |  |  | }
68 |  |  |  |  | }
69 |  |  |  |  | }
70 |  |  |  |  |
71 |  |  |  |  | # spent 1.28ms (381µs+896µs) within Class::XSAccessor::_generate_method which was called 36 times, avg 35µs/call: # 36 times (381µs+896µs) by Class::XSAccessor::import at line 57, avg 35µs/call sub _generate_method {
72 | 216 | 1.30ms |  |  | my ($caller_pkg, $subname, $hashkey, $opts, $type) = @_;
73 |  |  |  |  |
74 |  |  |  |  | croak("Cannot use undef as a hash key for generating an XS $type accessor. (Sub: $subname)")
75 |  |  |  |  | if not defined $hashkey;
76 |  |  |  |  |
77 |  |  | 36 | 36µs | $subname = "${caller_pkg}::$subname" if $subname !~ /::/; # spent 36µs making 36 calls to Class::XSAccessor::CORE:match, avg 989ns/call
78 |  |  |  |  |
79 |  |  |  |  | Class::XSAccessor::Heavy::check_sub_existence($subname) if not $opts->{replace};
80 | 3 | 137µs | 2 | 27µs | # spent 18µs (8+10) within Class::XSAccessor::BEGIN@80 which was called: # once (8µs+10µs) by Class::Accessor::Grouped::BEGIN@529 at line 80 no warnings 'redefine'; # don't warn about an explicitly requested redefine # spent 18µs making 1 call to Class::XSAccessor::BEGIN@80 # spent 10µs making 1 call to warnings::unimport
81 |  |  |  |  |
82 |  |  |  |  | if ($type eq 'getter') {
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 {
107 |  |  | 36 | 861µs | newxs_accessor($subname, $hashkey, $opts->{chained}||0); # spent 861µs making 36 calls to Class::XSAccessor::newxs_accessor, avg 24µs/call
108 |  |  |  |  | }
109 |  |  |  |  | }
110 |  |  |  |  |
111 | 1 | 23µs |  |  | 1;
112 |  |  |  |  |
113 |  |  |  |  | __END__
|  |  |  |  | # spent 36µs within Class::XSAccessor::CORE:match which was called 36 times, avg 989ns/call: # 36 times (36µs+0s) by Class::XSAccessor::_generate_method at line 77, avg 989ns/call sub Class::XSAccessor::CORE:match; # opcode
|  |  |  |  | # spent 14µs within Class::XSAccessor::END which was called: # once (14µs+0s) by main::RUNTIME at line 0 of xt/tapper-mcp-scheduler-with-db-longrun.t sub Class::XSAccessor::END; # xsub
|  |  |  |  | # spent 861µs within Class::XSAccessor::newxs_accessor which was called 36 times, avg 24µs/call: # 36 times (861µs+0s) by Class::XSAccessor::_generate_method at line 107, avg 24µs/call sub Class::XSAccessor::newxs_accessor; # xsub