← 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
StatementsExecuted 4735 statements in 9.45ms
Subroutines
Calls P F Exclusive
Time
Inclusive
Time
Subroutine
8711152µs152µsClass::MOP::Class::Immutable::Trait::::_get_mutable_metaclass_nameClass::MOP::Class::Immutable::Trait::_get_mutable_metaclass_name
11110µs21µsClass::MOP::Class::Immutable::Trait::::BEGIN@4Class::MOP::Class::Immutable::Trait::BEGIN@4
1119µs24µsClass::MOP::Class::Immutable::Trait::::BEGIN@8Class::MOP::Class::Immutable::Trait::BEGIN@8
1118µs12µsClass::MOP::Class::Immutable::Trait::::BEGIN@5Class::MOP::Class::Immutable::Trait::BEGIN@5
1118µs14µsClass::MOP::Class::Immutable::Trait::::BEGIN@39Class::MOP::Class::Immutable::Trait::BEGIN@39
1116µs15µsClass::MOP::Class::Immutable::Trait::::BEGIN@29Class::MOP::Class::Immutable::Trait::BEGIN@29
1114µs4µsClass::MOP::Class::Immutable::Trait::::BEGIN@7Class::MOP::Class::Immutable::Trait::BEGIN@7
0000s0sClass::MOP::Class::Immutable::Trait::::__ANON__[:35]Class::MOP::Class::Immutable::Trait::__ANON__[:35]
0000s0sClass::MOP::Class::Immutable::Trait::::__ANON__[:40]Class::MOP::Class::Immutable::Trait::__ANON__[:40]
0000s0sClass::MOP::Class::Immutable::Trait::::__throw_exceptionClass::MOP::Class::Immutable::Trait::__throw_exception
0000s0sClass::MOP::Class::Immutable::Trait::::_immutable_cannot_callClass::MOP::Class::Immutable::Trait::_immutable_cannot_call
0000s0sClass::MOP::Class::Immutable::Trait::::_immutable_metaclassClass::MOP::Class::Immutable::Trait::_immutable_metaclass
0000s0sClass::MOP::Class::Immutable::Trait::::_immutable_read_onlyClass::MOP::Class::Immutable::Trait::_immutable_read_only
0000s0sClass::MOP::Class::Immutable::Trait::::_method_mapClass::MOP::Class::Immutable::Trait::_method_map
0000s0sClass::MOP::Class::Immutable::Trait::::class_precedence_listClass::MOP::Class::Immutable::Trait::class_precedence_list
0000s0sClass::MOP::Class::Immutable::Trait::::get_all_attributesClass::MOP::Class::Immutable::Trait::get_all_attributes
0000s0sClass::MOP::Class::Immutable::Trait::::get_all_method_namesClass::MOP::Class::Immutable::Trait::get_all_method_names
0000s0sClass::MOP::Class::Immutable::Trait::::get_all_methodsClass::MOP::Class::Immutable::Trait::get_all_methods
0000s0sClass::MOP::Class::Immutable::Trait::::get_meta_instanceClass::MOP::Class::Immutable::Trait::get_meta_instance
0000s0sClass::MOP::Class::Immutable::Trait::::is_immutableClass::MOP::Class::Immutable::Trait::is_immutable
0000s0sClass::MOP::Class::Immutable::Trait::::is_mutableClass::MOP::Class::Immutable::Trait::is_mutable
0000s0sClass::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
1package Class::MOP::Class::Immutable::Trait;
219µsour $VERSION = '2.1604';
3
4222µs232µ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
5219µs216µ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
7219µs14µ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
82128µs238µ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
1187209µ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
13sub is_mutable { 0 }
1487140µssub is_immutable { 1 }
15
16sub _immutable_metaclass { ref $_[1] }
17
18sub _immutable_read_only {
19 my $name = shift;
20 __throw_exception( CallingReadOnlyMethodOnAnImmutableInstance => method_name => $name );
21}
22
23sub _immutable_cannot_call {
24 my $name = shift;
25 __throw_exception( CallingMethodOnAnImmutableInstance => method_name => $name );
26}
27
281700nsfor my $name (qw/superclasses/) {
29281µs224µ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 {
31132µs my $orig = shift;
32131µs my $self = shift;
33133µs _immutable_read_only($name) if @_;
341330µs13158µ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
3516µs };
36}
37
381400nsfor my $name (qw/add_method alias_method remove_method add_attribute remove_attribute remove_package_symbol add_package_symbol/) {
392278µs221µ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
40723µs *{__PACKAGE__."::$name"} = sub { _immutable_cannot_call($name) };
41}
42
43sub class_precedence_list {
44438µs my $orig = shift;
45436µs my $self = shift;
4643166µs130s @{ $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
50sub linearized_isa {
5112729µs my $orig = shift;
5212721µs my $self = shift;
53127427µs23219µ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
56sub get_all_methods {
57 my $orig = shift;
58 my $self = shift;
59 @{ $self->{__immutable}{get_all_methods} ||= [ $self->$orig ] };
60}
61
62sub get_all_method_names {
63 my $orig = shift;
64 my $self = shift;
65 @{ $self->{__immutable}{get_all_method_names} ||= [ $self->$orig ] };
66}
67
68sub get_all_attributes {
6929364µs my $orig = shift;
7029344µs my $self = shift;
712931.06ms17928µ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
74sub get_meta_instance {
75629105µs my $orig = shift;
7662961µs my $self = shift;
776295.35ms241.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
80sub _method_map {
8140366µs my $orig = shift;
8240350µs my $self = shift;
834031.02ms48184µ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.
89sub __throw_exception {
90 my ($exception_type, @args_to_exception) = @_;
91 die use_module( "Moose::Exception::$exception_type" )->new( @args_to_exception );
92}
93
9414µs1;
95
96# ABSTRACT: Implements immutability for metaclass objects
97
98__END__