Profile of Class/MOP/Class/Immutable/Trait.pm

← Index
NYTProf Performance Profile «line view»
For script/ponapi
Run on Wed Feb 10 15:51:26 2016
Reported on Thu Feb 11 09:43:10 2016

Filename | /usr/local/lib/perl/5.18.2/Class/MOP/Class/Immutable/Trait.pm
Statements | Executed 4735 statements in 9.45ms

Subroutines
Calls | P | F | Exclusive Time | Inclusive Time | Subroutine
--- | --- | --- | --- | --- | ---
87 | 1 | 1 | 152µs | 152µs | Class::MOP::Class::Immutable::Trait::::_get_mutable_metaclass_nameClass::MOP::Class::Immutable::Trait::_get_mutable_metaclass_name
1 | 1 | 1 | 10µs | 21µs | Class::MOP::Class::Immutable::Trait::::BEGIN@4Class::MOP::Class::Immutable::Trait::BEGIN@4
1 | 1 | 1 | 9µs | 24µs | Class::MOP::Class::Immutable::Trait::::BEGIN@8Class::MOP::Class::Immutable::Trait::BEGIN@8
1 | 1 | 1 | 8µs | 12µs | Class::MOP::Class::Immutable::Trait::::BEGIN@5Class::MOP::Class::Immutable::Trait::BEGIN@5
1 | 1 | 1 | 8µs | 14µs | Class::MOP::Class::Immutable::Trait::::BEGIN@39Class::MOP::Class::Immutable::Trait::BEGIN@39
1 | 1 | 1 | 6µs | 15µs | Class::MOP::Class::Immutable::Trait::::BEGIN@29Class::MOP::Class::Immutable::Trait::BEGIN@29
1 | 1 | 1 | 4µs | 4µs | Class::MOP::Class::Immutable::Trait::::BEGIN@7Class::MOP::Class::Immutable::Trait::BEGIN@7
0 | 0 | 0 | 0s | 0s | Class::MOP::Class::Immutable::Trait::::__ANON__[:35]Class::MOP::Class::Immutable::Trait::__ANON__[:35]
0 | 0 | 0 | 0s | 0s | Class::MOP::Class::Immutable::Trait::::__ANON__[:40]Class::MOP::Class::Immutable::Trait::__ANON__[:40]
0 | 0 | 0 | 0s | 0s | Class::MOP::Class::Immutable::Trait::::__throw_exceptionClass::MOP::Class::Immutable::Trait::__throw_exception
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::::_immutable_read_onlyClass::MOP::Class::Immutable::Trait::_immutable_read_only
0 | 0 | 0 | 0s | 0s | Class::MOP::Class::Immutable::Trait::::_method_mapClass::MOP::Class::Immutable::Trait::_method_map
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

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 | 1 | 9µs |  |  | our $VERSION = '2.1604';
3 |  |  |  |  |
4 | 2 | 22µs | 2 | 32µs | # spent 21µs (10+11) within Class::MOP::Class::Immutable::Trait::BEGIN@4 which was called: # once (10µs+11µs) by Module::Runtime::require_module at line 4 use strict; # spent 21µs making 1 call to Class::MOP::Class::Immutable::Trait::BEGIN@4 # spent 11µs making 1 call to strict::import
5 | 2 | 19µs | 2 | 16µs | # spent 12µs (8+4) within Class::MOP::Class::Immutable::Trait::BEGIN@5 which was called: # once (8µs+4µs) by Module::Runtime::require_module at line 5 use warnings; # spent 12µs making 1 call to Class::MOP::Class::Immutable::Trait::BEGIN@5 # spent 4µs making 1 call to warnings::import
6 |  |  |  |  |
7 | 2 | 19µs | 1 | 4µs | # spent 4µs within Class::MOP::Class::Immutable::Trait::BEGIN@7 which was called: # once (4µs+0s) by Module::Runtime::require_module at line 7 use MRO::Compat; # spent 4µs making 1 call to Class::MOP::Class::Immutable::Trait::BEGIN@7
8 | 2 | 128µs | 2 | 38µs | # spent 24µs (9+15) within Class::MOP::Class::Immutable::Trait::BEGIN@8 which was called: # once (9µs+15µs) by Module::Runtime::require_module at line 8 use Module::Runtime 'use_module'; # spent 24µs making 1 call to Class::MOP::Class::Immutable::Trait::BEGIN@8 # spent 15µs making 1 call to Module::Runtime::import
9 |  |  |  |  |
10 |  |  |  |  | # the original class of the metaclass instance
11 | 87 | 209µs |  |  | # spent 152µs within Class::MOP::Class::Immutable::Trait::_get_mutable_metaclass_name which was called 87 times, avg 2µs/call: # 87 times (152µs+0s) by Class::MOP::Class::_real_ref_name at line 122 of Class/MOP/Class.pm, avg 2µs/call sub _get_mutable_metaclass_name { $_[0]{__immutable}{original_class} }
12 |  |  |  |  |
13 |  |  |  |  | sub is_mutable { 0 }
14 | 87 | 140µs |  |  | sub is_immutable { 1 }
15 |  |  |  |  |
16 |  |  |  |  | sub _immutable_metaclass { ref $_[1] }
17 |  |  |  |  |
18 |  |  |  |  | sub _immutable_read_only {
19 |  |  |  |  | my $name = shift;
20 |  |  |  |  | __throw_exception( CallingReadOnlyMethodOnAnImmutableInstance => method_name => $name );
21 |  |  |  |  | }
22 |  |  |  |  |
23 |  |  |  |  | sub _immutable_cannot_call {
24 |  |  |  |  | my $name = shift;
25 |  |  |  |  | __throw_exception( CallingMethodOnAnImmutableInstance => method_name => $name );
26 |  |  |  |  | }
27 |  |  |  |  |
28 | 1 | 700ns |  |  | for my $name (qw/superclasses/) {
29 | 2 | 81µs | 2 | 24µs | # spent 15µs (6+9) within Class::MOP::Class::Immutable::Trait::BEGIN@29 which was called: # once (6µs+9µs) by Module::Runtime::require_module at line 29 no strict 'refs'; # spent 15µs making 1 call to Class::MOP::Class::Immutable::Trait::BEGIN@29 # spent 9µs making 1 call to strict::unimport
30 |  |  |  |  | *{__PACKAGE__."::$name"} = sub {
31 | 13 | 2µs |  |  | my $orig = shift;
32 | 13 | 1µs |  |  | my $self = shift;
33 | 13 | 3µs |  |  | _immutable_read_only($name) if @_;
34 | 13 | 30µs | 13 | 158µs | $self->$orig; # spent 130µs making 12 calls to Class::MOP::Class::superclasses, avg 11µs/call # spent 28µs making 1 call to Moose::Meta::Class::superclasses
35 | 1 | 6µs |  |  | };
36 |  |  |  |  | }
37 |  |  |  |  |
38 | 1 | 400ns |  |  | for my $name (qw/add_method alias_method remove_method add_attribute remove_attribute remove_package_symbol add_package_symbol/) {
39 | 2 | 278µs | 2 | 21µs | # spent 14µs (8+7) within Class::MOP::Class::Immutable::Trait::BEGIN@39 which was called: # once (8µs+7µs) by Module::Runtime::require_module at line 39 no strict 'refs'; # spent 14µs making 1 call to Class::MOP::Class::Immutable::Trait::BEGIN@39 # spent 7µs making 1 call to strict::unimport
40 | 7 | 23µs |  |  | *{__PACKAGE__."::$name"} = sub { _immutable_cannot_call($name) };
41 |  |  |  |  | }
42 |  |  |  |  |
43 |  |  |  |  | sub class_precedence_list {
44 | 43 | 8µs |  |  | my $orig = shift;
45 | 43 | 6µs |  |  | my $self = shift;
46 | 43 | 166µs | 13 | 0s | @{ $self->{__immutable}{class_precedence_list} # spent 1.40ms making 13 calls to Class::MOP::Class::class_precedence_list, avg 108µs/call, recursion: max depth 4, sum of overlapping time 1.40ms
47 |  |  |  |  | ||= [ $self->$orig ] };
48 |  |  |  |  | }
49 |  |  |  |  |
50 |  |  |  |  | sub linearized_isa {
51 | 127 | 29µs |  |  | my $orig = shift;
52 | 127 | 21µs |  |  | my $self = shift;
53 | 127 | 427µs | 23 | 219µs | @{ $self->{__immutable}{linearized_isa} ||= [ $self->$orig ] }; # spent 219µs making 23 calls to Class::MOP::Class::linearized_isa, avg 10µs/call
54 |  |  |  |  | }
55 |  |  |  |  |
56 |  |  |  |  | sub get_all_methods {
57 |  |  |  |  | my $orig = shift;
58 |  |  |  |  | my $self = shift;
59 |  |  |  |  | @{ $self->{__immutable}{get_all_methods} ||= [ $self->$orig ] };
60 |  |  |  |  | }
61 |  |  |  |  |
62 |  |  |  |  | sub get_all_method_names {
63 |  |  |  |  | my $orig = shift;
64 |  |  |  |  | my $self = shift;
65 |  |  |  |  | @{ $self->{__immutable}{get_all_method_names} ||= [ $self->$orig ] };
66 |  |  |  |  | }
67 |  |  |  |  |
68 |  |  |  |  | sub get_all_attributes {
69 | 293 | 64µs |  |  | my $orig = shift;
70 | 293 | 44µs |  |  | my $self = shift;
71 | 293 | 1.06ms | 17 | 928µs | @{ $self->{__immutable}{get_all_attributes} ||= [ $self->$orig ] }; # spent 928µs making 17 calls to Class::MOP::Class::get_all_attributes, avg 55µs/call
72 |  |  |  |  | }
73 |  |  |  |  |
74 |  |  |  |  | sub get_meta_instance {
75 | 629 | 105µs |  |  | my $orig = shift;
76 | 629 | 61µs |  |  | my $self = shift;
77 | 629 | 5.35ms | 24 | 1.38ms | $self->{__immutable}{get_meta_instance} ||= $self->$orig; # spent 1.38ms making 24 calls to Class::MOP::Class::get_meta_instance, avg 57µs/call
78 |  |  |  |  | }
79 |  |  |  |  |
80 |  |  |  |  | sub _method_map {
81 | 403 | 66µs |  |  | my $orig = shift;
82 | 403 | 50µs |  |  | my $self = shift;
83 | 403 | 1.02ms | 48 | 184µs | $self->{__immutable}{_method_map} ||= $self->$orig; # spent 174µs making 23 calls to Class::MOP::Mixin::HasMethods::_method_map, avg 8µs/call # spent 10µs making 25 calls to Class::MOP::Method::body, avg 404ns/call
84 |  |  |  |  | }
85 |  |  |  |  |
86 |  |  |  |  | # private method, for this file only -
87 |  |  |  |  | # if we declare a method here, it will behave differently depending on what
88 |  |  |  |  | # class this trait is applied to, so we won't have a reliable parameter list.
89 |  |  |  |  | sub __throw_exception {
90 |  |  |  |  | my ($exception_type, @args_to_exception) = @_;
91 |  |  |  |  | die use_module( "Moose::Exception::$exception_type" )->new( @args_to_exception );
92 |  |  |  |  | }
93 |  |  |  |  |
94 | 1 | 4µs |  |  | 1;
95 |  |  |  |  |
96 |  |  |  |  | # ABSTRACT: Implements immutability for metaclass objects
97 |  |  |  |  |
98 |  |  |  |  | __END__