← Index
NYTProf Performance Profile   « block view • line view • sub view »
For -e
  Run on Wed Nov 17 21:45:08 2010
Reported on Wed Nov 17 22:11:11 2010

Filename/home/doy/perl5/perlbrew/perls/perl-5.10.1/lib/site_perl/5.10.1/x86_64-linux/Moose/Object.pm
StatementsExecuted 111 statements in 5.79ms
Subroutines
Calls P F Exclusive
Time
Inclusive
Time
Subroutine
111797µs947µsMoose::Object::::BEGIN@13Moose::Object::BEGIN@13
4211782µs1.04msMoose::Object::::BUILDALLMoose::Object::BUILDALL
611363µs8.05msMoose::Object::::doesMoose::Object::does
111245µs252µsMoose::Object::::BEGIN@109Moose::Object::BEGIN@109
11190µs14.9msMoose::Object::::BEGIN@14Moose::Object::BEGIN@14
11175µs94µsMoose::Object::::BEGIN@4Moose::Object::BEGIN@4
11158µs127µsMoose::Object::::BEGIN@101Moose::Object::BEGIN@101
11147µs124µsMoose::Object::::BEGIN@83Moose::Object::BEGIN@83
11139µs122µsMoose::Object::::BEGIN@5Moose::Object::BEGIN@5
11121µs21µsMoose::Object::::BEGIN@10Moose::Object::BEGIN@10
11120µs20µsMoose::Object::::BEGIN@11Moose::Object::BEGIN@11
11119µs19µsMoose::Object::::BEGIN@7Moose::Object::BEGIN@7
11118µs18µsMoose::Object::::BEGIN@8Moose::Object::BEGIN@8
11118µs18µsMoose::Object::::BEGIN@9Moose::Object::BEGIN@9
0000s0sMoose::Object::::BUILDARGSMoose::Object::BUILDARGS
0000s0sMoose::Object::::DEMOLISHALLMoose::Object::DEMOLISHALL
0000s0sMoose::Object::::DESTROYMoose::Object::DESTROY
0000s0sMoose::Object::::__ANON__[:103]Moose::Object::__ANON__[:103]
0000s0sMoose::Object::::__ANON__[:97]Moose::Object::__ANON__[:97]
0000s0sMoose::Object::::dumpMoose::Object::dump
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
43100µs2112µs
# spent 94µs (75+18) within Moose::Object::BEGIN@4 which was called: # once (75µs+18µs) by Moose::BEGIN@25 at line 4
use strict;
# spent 94µs making 1 call to Moose::Object::BEGIN@4 # spent 18µs making 1 call to strict::import
5395µs2206µs
# spent 122µs (39+83) within Moose::Object::BEGIN@5 which was called: # once (39µs+83µs) by Moose::BEGIN@25 at line 5
use warnings;
# spent 122µs making 1 call to Moose::Object::BEGIN@5 # spent 83µs making 1 call to warnings::import
6
7376µs119µs
# spent 19µs within Moose::Object::BEGIN@7 which was called: # once (19µs+0s) by Moose::BEGIN@25 at line 7
use Carp ();
# spent 19µs making 1 call to Moose::Object::BEGIN@7
8375µs118µs
# spent 18µs within Moose::Object::BEGIN@8 which was called: # once (18µs+0s) by Moose::BEGIN@25 at line 8
use Devel::GlobalDestruction ();
# spent 18µs making 1 call to Moose::Object::BEGIN@8
9387µs118µs
# spent 18µs within Moose::Object::BEGIN@9 which was called: # once (18µs+0s) by Moose::BEGIN@25 at line 9
use MRO::Compat ();
# spent 18µs making 1 call to Moose::Object::BEGIN@9
10385µs121µs
# spent 21µs within Moose::Object::BEGIN@10 which was called: # once (21µs+0s) by Moose::BEGIN@25 at line 10
use Scalar::Util ();
# spent 21µs making 1 call to Moose::Object::BEGIN@10
113124µs120µs
# spent 20µs within Moose::Object::BEGIN@11 which was called: # once (20µs+0s) by Moose::BEGIN@25 at line 11
use Try::Tiny ();
# spent 20µs making 1 call to Moose::Object::BEGIN@11
12
133873µs2969µs
# spent 947µs (797+151) within Moose::Object::BEGIN@13 which was called: # once (797µs+151µs) by Moose::BEGIN@25 at line 13
use if ( not our $__mx_is_compiled ), 'Moose::Meta::Class';
# spent 947µs making 1 call to Moose::Object::BEGIN@13 # spent 21µs making 1 call to if::import
1431.38ms214.9ms
# spent 14.9ms (90µs+14.8) within Moose::Object::BEGIN@14 which was called: # once (90µs+14.8ms) by Moose::BEGIN@25 at line 14
use if ( not our $__mx_is_compiled ), metaclass => 'Moose::Meta::Class';
# spent 14.9ms making 1 call to Moose::Object::BEGIN@14 # spent 16µs making 1 call to if::import
15
1614µsour $VERSION = '1.19';
17182µs$VERSION = eval $VERSION;
# spent 9µs executing statements in string eval
1813µsour $AUTHORITY = 'cpan:STEVAN';
19
20sub new {
21 my $class = shift;
22 my $real_class = Scalar::Util::blessed($class) || $class;
23
24 my $params = $real_class->BUILDARGS(@_);
25
26 return Class::MOP::Class->initialize($real_class)->new_object($params);
27}
28
29sub BUILDARGS {
30 my $class = shift;
31 if ( scalar @_ == 1 ) {
32 unless ( defined $_[0] && ref $_[0] eq 'HASH' ) {
33 Class::MOP::class_of($class)->throw_error(
34 "Single parameters to new() must be a HASH ref",
35 data => $_[0] );
36 }
37 return { %{ $_[0] } };
38 }
39 elsif ( @_ % 2 ) {
40 Carp::carp(
41 "The new() method for $class expects a hash reference or a key/value list."
42 . " You passed an odd number of arguments" );
43 return { @_, undef };
44 }
45 else {
46 return {@_};
47 }
48}
49
50
# spent 1.04ms (782µs+254µs) within Moose::Object::BUILDALL which was called 42 times, avg 25µs/call: # 42 times (782µs+254µs) by Moose::Meta::Class::new_object at line 278 of Moose/Meta/Class.pm, avg 25µs/call
sub BUILDALL {
51 # NOTE: we ask Perl if we even
52 # need to do this first, to avoid
53 # extra meta level calls
54421.05ms42253µs return unless $_[0]->can('BUILD');
# spent 253µs making 42 calls to UNIVERSAL::can, avg 6µs/call
55 my ($self, $params) = @_;
56 foreach my $method (reverse Class::MOP::class_of($self)->find_all_methods_by_name('BUILD')) {
57 $method->{code}->execute($self, $params);
58 }
59}
60
61sub DEMOLISHALL {
62 my $self = shift;
63 my ($in_global_destruction) = @_;
64
65 # NOTE: we ask Perl if we even
66 # need to do this first, to avoid
67 # extra meta level calls
68 return unless $self->can('DEMOLISH');
69
70 my @isa;
71 if ( my $meta = Class::MOP::class_of($self ) ) {
72 @isa = $meta->linearized_isa;
73 } else {
74 # We cannot count on being able to retrieve a previously made
75 # metaclass, _or_ being able to make a new one during global
76 # destruction. However, we should still be able to use mro at
77 # that time (at least tests suggest so ;)
78 my $class_name = ref $self;
79 @isa = @{ mro::get_linear_isa($class_name) }
80 }
81
82 foreach my $class (@isa) {
833453µs2200µs
# spent 124µs (47+77) within Moose::Object::BEGIN@83 which was called: # once (47µs+77µs) by Moose::BEGIN@25 at line 83
no strict 'refs';
# spent 124µs making 1 call to Moose::Object::BEGIN@83 # spent 77µs making 1 call to strict::unimport
84 my $demolish = *{"${class}::DEMOLISH"}{CODE};
85 $self->$demolish($in_global_destruction)
86 if defined $demolish;
87 }
88}
89
90sub DESTROY {
91 my $self = shift;
92
93 local $?;
94
95 Try::Tiny::try {
96 $self->DEMOLISHALL(Devel::GlobalDestruction::in_global_destruction);
97 }
98 Try::Tiny::catch {
99 # Without this, Perl will warn "\t(in cleanup)$@" because of some
100 # bizarre fucked-up logic deep in the internals.
1013292µs2195µs
# spent 127µs (58+69) within Moose::Object::BEGIN@101 which was called: # once (58µs+69µs) by Moose::BEGIN@25 at line 101
no warnings 'misc';
# spent 127µs making 1 call to Moose::Object::BEGIN@101 # spent 69µs making 1 call to warnings::unimport
102 die $_;
103 };
104
105 return;
106}
107
108# support for UNIVERSAL::DOES ...
109
# spent 252µs (245+8) within Moose::Object::BEGIN@109 which was called: # once (245µs+8µs) by Moose::BEGIN@25 at line 116
BEGIN {
1102255µs18µs my $does = UNIVERSAL->can("DOES") ? "SUPER::DOES" : "isa";
# spent 8µs making 1 call to UNIVERSAL::can
111 eval 'sub DOES {
112 my ( $self, $class_or_role_name ) = @_;
113 return $self->'.$does.'($class_or_role_name)
114 || $self->does($class_or_role_name);
115 }';
1161377µs1252µs}
# spent 252µs making 1 call to Moose::Object::BEGIN@109
117
118# new does() methods will be created
119# as appropiate see Moose::Meta::Role
120
# spent 8.05ms (363µs+7.69) within Moose::Object::does which was called 6 times, avg 1.34ms/call: # 6 times (363µs+7.69ms) by Moose::Meta::Attribute::does at line 42 of Moose/Meta/Attribute.pm, avg 1.34ms/call
sub does {
12130365µs my ($self, $role_name) = @_;
1226202µs my $meta = Class::MOP::class_of($self);
# spent 202µs making 6 calls to Class::MOP::class_of, avg 34µs/call
123 (defined $role_name)
124 || $meta->throw_error("You must supply a role name to does()");
125127.48ms return 1 if $meta->can('does_role') && $meta->does_role($role_name);
# spent 7.44ms making 6 calls to Moose::Meta::Class::does_role, avg 1.24ms/call # spent 45µs making 6 calls to UNIVERSAL::can, avg 8µs/call
126 return 0;
127}
128
129sub dump {
130 my $self = shift;
131 require Data::Dumper;
132 local $Data::Dumper::Maxdepth = shift if @_;
133 Data::Dumper::Dumper $self;
134}
135
136113µs1;
137
138__END__