← Index
NYTProf Performance Profile   « line view »
For examples/Atom-timer.pl
  Run on Mon Aug 12 14:45:28 2013
Reported on Mon Aug 12 14:46:14 2013

Filename/Users/dde/perl5/perlbrew/perls/5.18.0t/lib/site_perl/5.18.0/darwin-thread-multi-2level/Moose/Object.pm
StatementsExecuted 54 statements in 1.25ms
Subroutines
Calls P F Exclusive
Time
Inclusive
Time
Subroutine
1114.02ms4.69msMoose::Object::::dumpMoose::Object::dump
111210µs232µsMoose::Object::::BEGIN@19Moose::Object::BEGIN@19
11149µs50µsMoose::Object::::BEGIN@108Moose::Object::BEGIN@108
41134µs60µsMoose::Object::::doesMoose::Object::does
11113µs1.66msMoose::Object::::BEGIN@20Moose::Object::BEGIN@20
1118µs8µsMoose::Object::::BEGIN@3Moose::Object::BEGIN@3
1116µs16µsMoose::Object::::BEGIN@85Moose::Object::BEGIN@85
1116µs9µsMoose::Object::::BEGIN@11Moose::Object::BEGIN@11
1116µs16µsMoose::Object::::BEGIN@10Moose::Object::BEGIN@10
1112µs2µsMoose::Object::::BEGIN@13Moose::Object::BEGIN@13
1112µs2µsMoose::Object::::BEGIN@14Moose::Object::BEGIN@14
1112µs2µsMoose::Object::::BEGIN@15Moose::Object::BEGIN@15
1112µs2µsMoose::Object::::BEGIN@16Moose::Object::BEGIN@16
1112µs2µsMoose::Object::::BEGIN@17Moose::Object::BEGIN@17
0000s0sMoose::Object::::BUILDALLMoose::Object::BUILDALL
0000s0sMoose::Object::::BUILDARGSMoose::Object::BUILDARGS
0000s0sMoose::Object::::DEMOLISHALLMoose::Object::DEMOLISHALL
0000s0sMoose::Object::::DESTROYMoose::Object::DESTROY
0000s0sMoose::Object::::__ANON__[:102]Moose::Object::__ANON__[:102]
0000s0sMoose::Object::::__ANON__[:99]Moose::Object::__ANON__[:99]
0000s0sMoose::Object::::newMoose::Object::new
Call graph for these subroutines as a Graphviz dot language file.
Line State
ments
Time
on line
Calls Time
in subs
Code
1
2package Moose::Object;
3
# spent 8µs within Moose::Object::BEGIN@3 which was called: # once (8µs+0s) by Moose::BEGIN@33 at line 5
BEGIN {
414µs $Moose::Object::AUTHORITY = 'cpan:STEVAN';
5130µs18µs}
# spent 8µs making 1 call to Moose::Object::BEGIN@3
6{
72900ns $Moose::Object::VERSION = '2.1005';
8}
9
10222µs226µs
# spent 16µs (6+10) within Moose::Object::BEGIN@10 which was called: # once (6µs+10µs) by Moose::BEGIN@33 at line 10
use strict;
# spent 16µs making 1 call to Moose::Object::BEGIN@10 # spent 10µs making 1 call to strict::import
11218µs212µs
# spent 9µs (6+3) within Moose::Object::BEGIN@11 which was called: # once (6µs+3µs) by Moose::BEGIN@33 at line 11
use warnings;
# spent 9µs making 1 call to Moose::Object::BEGIN@11 # spent 3µs making 1 call to warnings::import
12
13216µs12µs
# spent 2µs within Moose::Object::BEGIN@13 which was called: # once (2µs+0s) by Moose::BEGIN@33 at line 13
use Carp ();
# spent 2µs making 1 call to Moose::Object::BEGIN@13
14216µs12µs
# spent 2µs within Moose::Object::BEGIN@14 which was called: # once (2µs+0s) by Moose::BEGIN@33 at line 14
use Devel::GlobalDestruction ();
# spent 2µs making 1 call to Moose::Object::BEGIN@14
15215µs12µs
# spent 2µs within Moose::Object::BEGIN@15 which was called: # once (2µs+0s) by Moose::BEGIN@33 at line 15
use MRO::Compat ();
# spent 2µs making 1 call to Moose::Object::BEGIN@15
16215µs12µs
# spent 2µs within Moose::Object::BEGIN@16 which was called: # once (2µs+0s) by Moose::BEGIN@33 at line 16
use Scalar::Util ();
# spent 2µs making 1 call to Moose::Object::BEGIN@16
17224µs12µs
# spent 2µs within Moose::Object::BEGIN@17 which was called: # once (2µs+0s) by Moose::BEGIN@33 at line 17
use Try::Tiny ();
# spent 2µs making 1 call to Moose::Object::BEGIN@17
18
192230µs2235µs
# spent 232µs (210+22) within Moose::Object::BEGIN@19 which was called: # once (210µs+22µs) by Moose::BEGIN@33 at line 19
use if ( not our $__mx_is_compiled ), 'Moose::Meta::Class';
# spent 232µs making 1 call to Moose::Object::BEGIN@19 # spent 2µs making 1 call to if::import
202319µs21.66ms
# spent 1.66ms (13µs+1.64) within Moose::Object::BEGIN@20 which was called: # once (13µs+1.64ms) by Moose::BEGIN@33 at line 20
use if ( not our $__mx_is_compiled ), metaclass => 'Moose::Meta::Class';
# spent 1.66ms making 1 call to Moose::Object::BEGIN@20 # spent 2µs making 1 call to if::import
21
22sub new {
23 my $class = shift;
24 my $real_class = Scalar::Util::blessed($class) || $class;
25
26 my $params = $real_class->BUILDARGS(@_);
27
28 return Class::MOP::Class->initialize($real_class)->new_object($params);
29}
30
31sub BUILDARGS {
32 my $class = shift;
33 if ( scalar @_ == 1 ) {
34 unless ( defined $_[0] && ref $_[0] eq 'HASH' ) {
35 Class::MOP::class_of($class)->throw_error(
36 "Single parameters to new() must be a HASH ref",
37 data => $_[0] );
38 }
39 return { %{ $_[0] } };
40 }
41 elsif ( @_ % 2 ) {
42 Carp::carp(
43 "The new() method for $class expects a hash reference or a key/value list."
44 . " You passed an odd number of arguments" );
45 return { @_, undef };
46 }
47 else {
48 return {@_};
49 }
50}
51
52sub BUILDALL {
53 # NOTE: we ask Perl if we even
54 # need to do this first, to avoid
55 # extra meta level calls
56 return unless $_[0]->can('BUILD');
57 my ($self, $params) = @_;
58 foreach my $method (reverse Class::MOP::class_of($self)->find_all_methods_by_name('BUILD')) {
59 $method->{code}->execute($self, $params);
60 }
61}
62
63sub DEMOLISHALL {
64 my $self = shift;
65 my ($in_global_destruction) = @_;
66
67 # NOTE: we ask Perl if we even
68 # need to do this first, to avoid
69 # extra meta level calls
70 return unless $self->can('DEMOLISH');
71
72 my @isa;
73 if ( my $meta = Class::MOP::class_of($self ) ) {
74 @isa = $meta->linearized_isa;
75 } else {
76 # We cannot count on being able to retrieve a previously made
77 # metaclass, _or_ being able to make a new one during global
78 # destruction. However, we should still be able to use mro at
79 # that time (at least tests suggest so ;)
80 my $class_name = ref $self;
81 @isa = @{ mro::get_linear_isa($class_name) }
82 }
83
84 foreach my $class (@isa) {
852146µs226µs
# spent 16µs (6+10) within Moose::Object::BEGIN@85 which was called: # once (6µs+10µs) by Moose::BEGIN@33 at line 85
no strict 'refs';
# spent 16µs making 1 call to Moose::Object::BEGIN@85 # spent 10µs making 1 call to strict::unimport
86 my $demolish = *{"${class}::DEMOLISH"}{CODE};
87 $self->$demolish($in_global_destruction)
88 if defined $demolish;
89 }
90}
91
92sub DESTROY {
93 my $self = shift;
94
95 local $?;
96
97 Try::Tiny::try {
98 $self->DEMOLISHALL(Devel::GlobalDestruction::in_global_destruction);
99 }
100 Try::Tiny::catch {
101 die $_;
102 };
103
104 return;
105}
106
107# support for UNIVERSAL::DOES ...
108
# spent 50µs (49+900ns) within Moose::Object::BEGIN@108 which was called: # once (49µs+900ns) by Moose::BEGIN@33 at line 115
BEGIN {
10915µs1900ns my $does = UNIVERSAL->can("DOES") ? "SUPER::DOES" : "isa";
# spent 900ns making 1 call to UNIVERSAL::can
110145µs eval 'sub DOES {
111 my ( $self, $class_or_role_name ) = @_;
112 return $self->'.$does.'($class_or_role_name)
113 || $self->does($class_or_role_name);
114 }';
1151118µs150µs}
# spent 50µs making 1 call to Moose::Object::BEGIN@108
116
117# new does() methods will be created
118# as appropriate see Moose::Meta::Role
119
# spent 60µs (34+26) within Moose::Object::does which was called 4 times, avg 15µs/call: # 4 times (34µs+26µs) by Moose::Meta::Attribute::does at line 47 of Moose/Meta/Attribute.pm, avg 15µs/call
sub does {
12042µs my ($self, $role_name) = @_;
121410µs42µs my $class = Scalar::Util::blessed($self) || $self;
# spent 2µs making 4 calls to Scalar::Util::blessed, avg 375ns/call
12246µs417µs my $meta = Class::MOP::Class->initialize($class);
# spent 17µs making 4 calls to Class::MOP::Class::initialize, avg 4µs/call
1234600ns (defined $role_name)
124 || $meta->throw_error("You must supply a role name to does()");
125415µs47µs return 1 if $meta->can('does_role') && $meta->does_role($role_name);
# spent 7µs making 4 calls to UNIVERSAL::can, avg 2µs/call
12648µs return 0;
127}
128
129
# spent 4.69ms (4.02+671µs) within Moose::Object::dump which was called: # once (4.02ms+671µs) by main::RUNTIME at line 27 of examples/Atom-timer.pl
sub dump {
1301400ns my $self = shift;
1311176µs require Data::Dumper;
1321400ns local $Data::Dumper::Maxdepth = shift if @_;
13316µs1109µs Data::Dumper::Dumper $self;
# spent 109µs making 1 call to Data::Dumper::Dumper
134}
135
13613µs1;
137
138# ABSTRACT: The base object for Moose
139
140__END__