← Index
NYTProf Performance Profile   « line view »
For fastest.pl
  Run on Fri Jan 31 20:48:16 2014
Reported on Fri Jan 31 20:49:42 2014

Filename/opt/perl-5.18.1/lib/site_perl/5.18.1/darwin-thread-multi-2level/Class/XSAccessor.pm
StatementsExecuted 150 statements in 1.73ms
Subroutines
Calls P F Exclusive
Time
Inclusive
Time
Subroutine
111521µs683µsClass::XSAccessor::::BEGIN@6Class::XSAccessor::BEGIN@6
222142µs269µsClass::XSAccessor::::importClass::XSAccessor::import
22135µs103µsClass::XSAccessor::::_generate_methodClass::XSAccessor::_generate_method
168125µs25µsClass::XSAccessor::::_make_hashClass::XSAccessor::_make_hash
11124µs24µsClass::XSAccessor::::newxs_getterClass::XSAccessor::newxs_getter (xsub)
11120µs20µsClass::XSAccessor::::BEGIN@2Class::XSAccessor::BEGIN@2
11112µs25µsClass::XSAccessor::::BEGIN@84Class::XSAccessor::BEGIN@84
11110µs10µsClass::XSAccessor::::newxs_constructorClass::XSAccessor::newxs_constructor (xsub)
1119µs14µsClass::XSAccessor::::BEGIN@4Class::XSAccessor::BEGIN@4
1119µs41µsClass::XSAccessor::::BEGIN@5Class::XSAccessor::BEGIN@5
1118µs24µsClass::XSAccessor::::BEGIN@3Class::XSAccessor::BEGIN@3
1116µs6µsClass::XSAccessor::::BEGIN@7Class::XSAccessor::BEGIN@7
1112µs2µsClass::XSAccessor::::ENDClass::XSAccessor::END (xsub)
2112µs2µsClass::XSAccessor::::CORE:matchClass::XSAccessor::CORE:match (opcode)
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;
2262µs120µs
# spent 20µs within Class::XSAccessor::BEGIN@2 which was called: # once (20µs+0s) by Object::Tiny::XS::BEGIN@28 at line 2
use 5.008;
# spent 20µs making 1 call to Class::XSAccessor::BEGIN@2
3230µs240µs
# spent 24µs (8+16) within Class::XSAccessor::BEGIN@3 which was called: # once (8µs+16µs) by Object::Tiny::XS::BEGIN@28 at line 3
use strict;
# spent 24µs making 1 call to Class::XSAccessor::BEGIN@3 # spent 16µs making 1 call to strict::import
4232µs219µs
# spent 14µs (9+5) within Class::XSAccessor::BEGIN@4 which was called: # once (9µs+5µs) by Object::Tiny::XS::BEGIN@28 at line 4
use warnings;
# spent 14µs making 1 call to Class::XSAccessor::BEGIN@4 # spent 5µs making 1 call to warnings::import
5232µs272µs
# spent 41µs (9+31) within Class::XSAccessor::BEGIN@5 which was called: # once (9µs+31µs) by Object::Tiny::XS::BEGIN@28 at line 5
use Carp qw/croak/;
# spent 41µs making 1 call to Class::XSAccessor::BEGIN@5 # spent 31µs making 1 call to Exporter::import
62145µs1683µs
# spent 683µs (521+162) within Class::XSAccessor::BEGIN@6 which was called: # once (521µs+162µs) by Object::Tiny::XS::BEGIN@28 at line 6
use Class::XSAccessor::Heavy;
# spent 683µs making 1 call to Class::XSAccessor::BEGIN@6
72564µs16µs
# spent 6µs within Class::XSAccessor::BEGIN@7 which was called: # once (6µs+0s) by Object::Tiny::XS::BEGIN@28 at line 7
use XSLoader;
# spent 6µs making 1 call to Class::XSAccessor::BEGIN@7
8
91800nsour $VERSION = '1.19';
10
111390µs1380µsXSLoader::load('Class::XSAccessor', $VERSION);
# spent 380µs making 1 call to XSLoader::load
12
13
# spent 25µs within Class::XSAccessor::_make_hash which was called 16 times, avg 2µs/call: # 2 times (5µs+0s) by Class::XSAccessor::import at line 37, avg 3µs/call # 2 times (3µs+0s) by Class::XSAccessor::import at line 38, avg 2µs/call # 2 times (3µs+0s) by Class::XSAccessor::import at line 43, avg 2µs/call # 2 times (3µs+0s) by Class::XSAccessor::import at line 39, avg 1µs/call # 2 times (3µs+0s) by Class::XSAccessor::import at line 41, avg 1µs/call # 2 times (3µs+0s) by Class::XSAccessor::import at line 42, avg 1µs/call # 2 times (3µs+0s) by Class::XSAccessor::import at line 44, avg 1µs/call # 2 times (3µs+0s) by Class::XSAccessor::import at line 40, avg 1µs/call
sub _make_hash {
14162µs my $ref = shift;
15
16164µs if (ref ($ref)) {
17 if (ref($ref) eq 'ARRAY') {
18 $ref = { map { $_ => $_ } @$ref }
19 }
20 } else {
21 $ref = { $ref, $ref };
22 }
23
241644µs return $ref;
25}
26
27
# spent 269µs (142+127) within Class::XSAccessor::import which was called 2 times, avg 135µs/call: # once (80µs+62µs) by Object::Tiny::XS::BEGIN@28 at line 28 of Object/Tiny/XS.pm # once (62µs+65µs) by Foo::Object::Tiny::XS::BEGIN@3 at line 5 of (eval 438)[Object/Tiny/XS.pm:18]
sub import {
282900ns my $own_class = shift;
2923µs my ($caller_pkg) = caller();
30
31 # Support both { getters => ... } and plain getters => ...
3224µs my %opts = ref($_[0]) eq 'HASH' ? %{$_[0]} : @_;
33
3421µs $caller_pkg = $opts{class} if defined $opts{class};
35
36 # TODO: Refactor. Move more duplicated code to ::Heavy
3723µs25µs my $read_subs = _make_hash($opts{getters} || {});
# spent 5µs making 2 calls to Class::XSAccessor::_make_hash, avg 3µs/call
3823µs23µs my $set_subs = _make_hash($opts{setters} || {});
# spent 3µs making 2 calls to Class::XSAccessor::_make_hash, avg 2µs/call
3922µs23µs my $acc_subs = _make_hash($opts{accessors} || {});
# spent 3µs making 2 calls to Class::XSAccessor::_make_hash, avg 1µs/call
4022µs23µs my $lvacc_subs = _make_hash($opts{lvalue_accessors} || {});
# spent 3µs making 2 calls to Class::XSAccessor::_make_hash, avg 1µs/call
4122µs23µs my $pred_subs = _make_hash($opts{predicates} || {});
# spent 3µs making 2 calls to Class::XSAccessor::_make_hash, avg 1µs/call
4222µs23µs my $ex_pred_subs = _make_hash($opts{exists_predicates} || {});
# spent 3µs making 2 calls to Class::XSAccessor::_make_hash, avg 1µs/call
4322µs23µs my $def_pred_subs = _make_hash($opts{defined_predicates} || {});
# spent 3µs making 2 calls to Class::XSAccessor::_make_hash, avg 2µs/call
4422µs23µs my $test_subs = _make_hash($opts{__tests__} || {});
# spent 3µs making 2 calls to Class::XSAccessor::_make_hash, avg 1µs/call
4522µs my $construct_subs = $opts{constructors} || [defined($opts{constructor}) ? $opts{constructor} : ()];
462600ns my $true_subs = $opts{true} || [];
472600ns my $false_subs = $opts{false} || [];
48
49219µ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 {
58163µs my $subs = $subtype->[1];
591616µs foreach my $subname (keys %$subs) {
601500ns my $hashkey = $subs->{$subname};
6112µs153µs _generate_method($caller_pkg, $subname, $hashkey, \%opts, $subtype->[0]);
# spent 53µs making 1 call to Class::XSAccessor::_generate_method
62 }
63 }
64
65216µs foreach my $subtype ( ["constructor", $construct_subs],
66 ["true", $true_subs],
67 ["false", $false_subs] )
68 {
6964µs foreach my $subname (@{$subtype->[1]}) {
7013µs149µs _generate_method($caller_pkg, $subname, "", \%opts, $subtype->[0]);
# spent 49µs making 1 call to Class::XSAccessor::_generate_method
71 }
72 }
73}
74
75
# spent 103µs (35+67) within Class::XSAccessor::_generate_method which was called 2 times, avg 51µs/call: # once (14µs+39µs) by Class::XSAccessor::import at line 61 # once (21µs+29µs) by Class::XSAccessor::import at line 70
sub _generate_method {
7622µs my ($caller_pkg, $subname, $hashkey, $opts, $type) = @_;
77
782400ns croak("Cannot use undef as a hash key for generating an XS $type accessor. (Sub: $subname)")
79 if not defined $hashkey;
80
81211µs22µs $subname = "${caller_pkg}::$subname" if $subname !~ /::/;
# spent 2µs making 2 calls to Class::XSAccessor::CORE:match, avg 950ns/call
82
8322µs232µs Class::XSAccessor::Heavy::check_sub_existence($subname) if not $opts->{replace};
# spent 32µs making 2 calls to Class::XSAccessor::Heavy::check_sub_existence, avg 16µs/call
842252µs237µs
# spent 25µs (12+12) within Class::XSAccessor::BEGIN@84 which was called: # once (12µs+12µs) by Object::Tiny::XS::BEGIN@28 at line 84
no warnings 'redefine'; # don't warn about an explicitly requested redefine
# spent 25µs making 1 call to Class::XSAccessor::BEGIN@84 # spent 12µs making 1 call to warnings::unimport
85
86253µs233µs if ($type eq 'getter') {
# spent 24µs making 1 call to Class::XSAccessor::newxs_getter # spent 10µs making 1 call to Class::XSAccessor::newxs_constructor
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 newxs_accessor($subname, $hashkey, $opts->{chained}||0);
115 }
116}
117
11815µs1;
119
120__END__
 
# spent 2µs within Class::XSAccessor::CORE:match which was called 2 times, avg 950ns/call: # 2 times (2µs+0s) by Class::XSAccessor::_generate_method at line 81, avg 950ns/call
sub Class::XSAccessor::CORE:match; # opcode
# spent 2µs within Class::XSAccessor::END which was called: # once (2µs+0s) by main::RUNTIME at line 0 of fastest.pl
sub Class::XSAccessor::END; # xsub
# spent 10µs within Class::XSAccessor::newxs_constructor which was called: # once (10µs+0s) by Class::XSAccessor::_generate_method at line 86
sub Class::XSAccessor::newxs_constructor; # xsub
# spent 24µs within Class::XSAccessor::newxs_getter which was called: # once (24µs+0s) by Class::XSAccessor::_generate_method at line 86
sub Class::XSAccessor::newxs_getter; # xsub