Profile of /usr/local/lib/perl5/site_perl/5.10.1/darwin-2level/Class/MOP/Class/Immutable/Trait.pm

← Index
NYTProf Performance Profile «block view•line view•sub view»
For 05.Domain_and_Item.t
Run on Tue May 4 17:21:41 2010
Reported on Tue May 4 17:22:29 2010

File | /usr/local/lib/perl5/site_perl/5.10.1/darwin-2level/Class/MOP/Class/Immutable/Trait.pm
Statements Executed | 2954
Statement Execution Time | 3.90ms

Subroutines — ordered by exclusive time
Calls | P | F | Exclusive Time | Inclusive Time | Subroutine
--- | --- | --- | --- | --- | ---
109 | 5 | 2 | 255µs | 255µs | Class::MOP::Class::Immutable::Trait::::_get_mutable_metaclass_nameClass::MOP::Class::Immutable::Trait::_get_mutable_metaclass_name
1 | 1 | 1 | 14µs | 17µs | Class::MOP::Class::Immutable::Trait::::BEGIN@3Class::MOP::Class::Immutable::Trait::BEGIN@3
1 | 1 | 1 | 7µs | 24µs | Class::MOP::Class::Immutable::Trait::::BEGIN@36Class::MOP::Class::Immutable::Trait::BEGIN@36
1 | 1 | 1 | 7µs | 16µs | Class::MOP::Class::Immutable::Trait::::BEGIN@4Class::MOP::Class::Immutable::Trait::BEGIN@4
1 | 1 | 1 | 6µs | 32µs | Class::MOP::Class::Immutable::Trait::::BEGIN@9Class::MOP::Class::Immutable::Trait::BEGIN@9
1 | 1 | 1 | 6µs | 35µs | Class::MOP::Class::Immutable::Trait::::BEGIN@8Class::MOP::Class::Immutable::Trait::BEGIN@8
1 | 1 | 1 | 4µs | 4µs | Class::MOP::Class::Immutable::Trait::::BEGIN@6Class::MOP::Class::Immutable::Trait::BEGIN@6
0 | 0 | 0 | 0s | 0s | Class::MOP::Class::Immutable::Trait::::__ANON__[:37]Class::MOP::Class::Immutable::Trait::__ANON__[:37]
0 | 0 | 0 | 0s | 0s | Class::MOP::Class::Immutable::Trait::::_get_method_mapClass::MOP::Class::Immutable::Trait::_get_method_map
0 | 0 | 0 | 0s | 0s | Class::MOP::Class::Immutable::Trait::::_immutable_cannot_callClass::MOP::Class::Immutable::Trait::_immutable_cannot_call
0 | 0 | 0 | 0s | 0s | Class::MOP::Class::Immutable::Trait::::_immutable_metaclassClass::MOP::Class::Immutable::Trait::_immutable_metaclass
0 | 0 | 0 | 0s | 0s | Class::MOP::Class::Immutable::Trait::::add_package_symbolClass::MOP::Class::Immutable::Trait::add_package_symbol
0 | 0 | 0 | 0s | 0s | Class::MOP::Class::Immutable::Trait::::class_precedence_listClass::MOP::Class::Immutable::Trait::class_precedence_list
0 | 0 | 0 | 0s | 0s | Class::MOP::Class::Immutable::Trait::::get_all_attributesClass::MOP::Class::Immutable::Trait::get_all_attributes
0 | 0 | 0 | 0s | 0s | Class::MOP::Class::Immutable::Trait::::get_all_method_namesClass::MOP::Class::Immutable::Trait::get_all_method_names
0 | 0 | 0 | 0s | 0s | Class::MOP::Class::Immutable::Trait::::get_all_methodsClass::MOP::Class::Immutable::Trait::get_all_methods
0 | 0 | 0 | 0s | 0s | Class::MOP::Class::Immutable::Trait::::get_meta_instanceClass::MOP::Class::Immutable::Trait::get_meta_instance
0 | 0 | 0 | 0s | 0s | Class::MOP::Class::Immutable::Trait::::is_immutableClass::MOP::Class::Immutable::Trait::is_immutable
0 | 0 | 0 | 0s | 0s | Class::MOP::Class::Immutable::Trait::::is_mutableClass::MOP::Class::Immutable::Trait::is_mutable
0 | 0 | 0 | 0s | 0s | Class::MOP::Class::Immutable::Trait::::linearized_isaClass::MOP::Class::Immutable::Trait::linearized_isa
0 | 0 | 0 | 0s | 0s | Class::MOP::Class::Immutable::Trait::::superclassesClass::MOP::Class::Immutable::Trait::superclasses

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::MOP::Class::Immutable::Trait;
2 |  |  |  |  |
3 | 3 | 21µs | 2 | 20µs | # spent 17µs (14+3) within Class::MOP::Class::Immutable::Trait::BEGIN@3 which was called # once (14µs+3µs) by Class::MOP::__ANON__[/usr/local/lib/perl5/site_perl/5.10.1/darwin-2level/Class/MOP.pm:103] at line 3 use strict; # spent 17µs making 1 call to Class::MOP::Class::Immutable::Trait::BEGIN@3 # spent 3µs making 1 call to strict::import
4 | 3 | 19µs | 2 | 25µs | # spent 16µs (7+9) within Class::MOP::Class::Immutable::Trait::BEGIN@4 which was called # once (7µs+9µs) by Class::MOP::__ANON__[/usr/local/lib/perl5/site_perl/5.10.1/darwin-2level/Class/MOP.pm:103] at line 4 use warnings; # spent 16µs making 1 call to Class::MOP::Class::Immutable::Trait::BEGIN@4 # spent 9µs making 1 call to warnings::import
5 |  |  |  |  |
6 | 3 | 20µs | 1 | 4µs | # spent 4µs within Class::MOP::Class::Immutable::Trait::BEGIN@6 which was called # once (4µs+0s) by Class::MOP::__ANON__[/usr/local/lib/perl5/site_perl/5.10.1/darwin-2level/Class/MOP.pm:103] at line 6 use MRO::Compat; # spent 4µs making 1 call to Class::MOP::Class::Immutable::Trait::BEGIN@6
7 |  |  |  |  |
8 | 3 | 24µs | 2 | 64µs | # spent 35µs (6+29) within Class::MOP::Class::Immutable::Trait::BEGIN@8 which was called # once (6µs+29µs) by Class::MOP::__ANON__[/usr/local/lib/perl5/site_perl/5.10.1/darwin-2level/Class/MOP.pm:103] at line 8 use Carp 'confess'; # spent 35µs making 1 call to Class::MOP::Class::Immutable::Trait::BEGIN@8 # spent 29µs making 1 call to Exporter::import
9 | 3 | 159µs | 2 | 58µs | # spent 32µs (6+26) within Class::MOP::Class::Immutable::Trait::BEGIN@9 which was called # once (6µs+26µs) by Class::MOP::__ANON__[/usr/local/lib/perl5/site_perl/5.10.1/darwin-2level/Class/MOP.pm:103] at line 9 use Scalar::Util 'blessed', 'weaken'; # spent 32µs making 1 call to Class::MOP::Class::Immutable::Trait::BEGIN@9 # spent 26µs making 1 call to Exporter::import
10 |  |  |  |  |
11 | 1 | 700ns |  |  | our $VERSION = '0.98';
12 | 1 | 14µs |  |  | $VERSION = eval $VERSION;
13 | 1 | 300ns |  |  | our $AUTHORITY = 'cpan:STEVAN';
14 |  |  |  |  |
15 |  |  |  |  | # the original class of the metaclass instance
16 | 109 | 344µs |  |  | # spent 255µs within Class::MOP::Class::Immutable::Trait::_get_mutable_metaclass_name which was called 109 times, avg 2µs/call: # 90 times (189µs+0s) by Class::MOP::Class::_check_metaclass_compatibility at line 185 of Class/MOP/Class.pm, avg 2µs/call # 16 times (59µs+0s) by Moose::Meta::Class::_superclass_meta_is_compatible at line 373 of Moose/Meta/Class.pm, avg 4µs/call # once (3µs+0s) by Class::MOP::Class::_immutable_metaclass at line 956 of Class/MOP/Class.pm # once (2µs+0s) by Class::MOP::Class::_construct_class_instance at line 71 of Class/MOP/Class.pm # once (2µs+0s) by Moose::Meta::Class::_reconcile_with_superclass_meta at line 397 of Moose/Meta/Class.pm sub _get_mutable_metaclass_name { $_[0]{__immutable}{original_class} }
17 |  |  |  |  |
18 |  |  |  |  | sub is_mutable { 0 }
19 | 109 | 215µs |  |  | sub is_immutable { 1 }
20 |  |  |  |  |
21 |  |  |  |  | sub _immutable_metaclass { ref $_[1] }
22 |  |  |  |  |
23 |  |  |  |  | sub superclasses {
24 | 48 | 31µs |  |  | my $orig = shift;
25 |  |  |  |  | my $self = shift;
26 |  |  |  |  | confess "This method is read-only" if @_;
27 |  |  |  |  | $self->$orig; # spent 215µs making 12 calls to Class::MOP::Class::superclasses, avg 18µs/call
28 |  |  |  |  | }
29 |  |  |  |  |
30 |  |  |  |  | sub _immutable_cannot_call {
31 |  |  |  |  | my $name = shift;
32 |  |  |  |  | Carp::confess "The '$name' method cannot be called on an immutable instance";
33 |  |  |  |  | }
34 |  |  |  |  |
35 | 1 | 800ns |  |  | for my $name (qw/add_method alias_method remove_method add_attribute remove_attribute remove_package_symbol/) {
36 | 3 | 274µs | 2 | 41µs | # spent 24µs (7+17) within Class::MOP::Class::Immutable::Trait::BEGIN@36 which was called # once (7µs+17µs) by Class::MOP::__ANON__[/usr/local/lib/perl5/site_perl/5.10.1/darwin-2level/Class/MOP.pm:103] at line 36 no strict 'refs'; # spent 24µs making 1 call to Class::MOP::Class::Immutable::Trait::BEGIN@36 # spent 17µs making 1 call to strict::unimport
37 | 6 | 20µs |  |  | *{__PACKAGE__."::$name"} = sub { _immutable_cannot_call($name) };
38 |  |  |  |  | }
39 |  |  |  |  |
40 |  |  |  |  | sub class_precedence_list {
41 | 75 | 113µs |  |  | my $orig = shift;
42 |  |  |  |  | my $self = shift;
43 |  |  |  |  | @{ $self->{__immutable}{class_precedence_list} # spent 1.95ms making 12 calls to Class::MOP::Class::class_precedence_list, avg 162µs/call, recursion: max depth 5, time 1.95ms
44 |  |  |  |  | ||= [ $self->$orig ] };
45 |  |  |  |  | }
46 |  |  |  |  |
47 |  |  |  |  | sub linearized_isa {
48 | 174 | 219µs |  |  | my $orig = shift;
49 |  |  |  |  | my $self = shift;
50 |  |  |  |  | @{ $self->{__immutable}{linearized_isa} ||= [ $self->$orig ] }; # spent 55µs making 7 calls to Class::MOP::Class::linearized_isa, avg 8µs/call
51 |  |  |  |  | }
52 |  |  |  |  |
53 |  |  |  |  | sub get_all_methods {
54 |  |  |  |  | my $orig = shift;
55 |  |  |  |  | my $self = shift;
56 |  |  |  |  | @{ $self->{__immutable}{get_all_methods} ||= [ $self->$orig ] };
57 |  |  |  |  | }
58 |  |  |  |  |
59 |  |  |  |  | sub get_all_method_names {
60 |  |  |  |  | my $orig = shift;
61 |  |  |  |  | my $self = shift;
62 |  |  |  |  | @{ $self->{__immutable}{get_all_method_names} ||= [ $self->$orig ] };
63 |  |  |  |  | }
64 |  |  |  |  |
65 |  |  |  |  | sub get_all_attributes {
66 | 816 | 977µs |  |  | my $orig = shift;
67 |  |  |  |  | my $self = shift;
68 |  |  |  |  | @{ $self->{__immutable}{get_all_attributes} ||= [ $self->$orig ] }; # spent 496µs making 6 calls to Class::MOP::Class::get_all_attributes, avg 83µs/call
69 |  |  |  |  | }
70 |  |  |  |  |
71 |  |  |  |  | sub get_meta_instance {
72 | 1494 | 1.25ms |  |  | my $orig = shift;
73 |  |  |  |  | my $self = shift;
74 |  |  |  |  | $self->{__immutable}{get_meta_instance} ||= $self->$orig; # spent 14µs making 6 calls to Class::MOP::Class::get_meta_instance, avg 2µs/call
75 |  |  |  |  | }
76 |  |  |  |  |
77 |  |  |  |  | sub _get_method_map {
78 |  |  |  |  | my $orig = shift;
79 |  |  |  |  | my $self = shift;
80 |  |  |  |  | $self->{__immutable}{_get_method_map} ||= $self->$orig;
81 |  |  |  |  | }
82 |  |  |  |  |
83 |  |  |  |  | sub add_package_symbol {
84 | 100 | 192µs |  |  | my $orig = shift;
85 |  |  |  |  | my $self = shift;
86 |  |  |  |  | confess "Cannot add package symbols to an immutable metaclass"
87 |  |  |  |  | unless ( caller(3) )[3] eq 'Class::MOP::Package::get_package_symbol';
88 |  |  |  |  |
89 |  |  |  |  | $self->$orig(@_); # spent 122µs making 25 calls to Class::MOP::Package::add_package_symbol, avg 5µs/call
90 |  |  |  |  | }
91 |  |  |  |  |
92 | 1 | 13µs |  |  | 1;
93 |  |  |  |  |
94 |  |  |  |  | __END__
95 |  |  |  |  |
96 |  |  |  |  | =pod
97 |  |  |  |  |
98 |  |  |  |  | =head1 NAME
99 |  |  |  |  |
100 |  |  |  |  | Class::MOP::Class::Immutable::Trait - Implements immutability for metaclass objects
101 |  |  |  |  |
102 |  |  |  |  | =head1 DESCRIPTION
103 |  |  |  |  |
104 |  |  |  |  | This class provides a pseudo-trait that is applied to immutable metaclass
105 |  |  |  |  | objects. In reality, it is simply a parent class.
106 |  |  |  |  |
107 |  |  |  |  | It implements caching and read-only-ness for various metaclass methods.
108 |  |  |  |  |
109 |  |  |  |  | =head1 AUTHOR
110 |  |  |  |  |
111 |  |  |  |  | Yuval Kogman E<lt>nothingmuch@cpan.orgE<gt>
112 |  |  |  |  |
113 |  |  |  |  | =head1 COPYRIGHT AND LICENSE
114 |  |  |  |  |
115 |  |  |  |  | Copyright 2009 by Infinity Interactive, Inc.
116 |  |  |  |  |
117 |  |  |  |  | L<http://www.iinteractive.com>
118 |  |  |  |  |
119 |  |  |  |  | This library is free software; you can redistribute it and/or modify
120 |  |  |  |  | it under the same terms as Perl itself.
121 |  |  |  |  |
122 |  |  |  |  | =cut
123 |  |  |  |  |