← Index
NYTProf Performance Profile   « line view »
For /home/ss5/perl5/perlbrew/perls/perl-5.22.0/bin/benchmarkanything-storage
  Run on Mon Jan 29 16:55:34 2018
Reported on Mon Jan 29 16:57:06 2018

Filename/home/ss5/perl5/perlbrew/perls/perl-5.22.0/lib/site_perl/5.22.0/x86_64-linux/Class/MOP/Class/Immutable/Trait.pm
StatementsExecuted 2020 statements in 5.70ms
Subroutines
Calls P F Exclusive
Time
Inclusive
Time
Subroutine
231134µs34µsClass::MOP::Class::Immutable::Trait::::_get_mutable_metaclass_nameClass::MOP::Class::Immutable::Trait::_get_mutable_metaclass_name
11110µs12µsClass::MOP::Class::Immutable::Trait::::BEGIN@4Class::MOP::Class::Immutable::Trait::BEGIN@4
1116µs17µsClass::MOP::Class::Immutable::Trait::::BEGIN@8Class::MOP::Class::Immutable::Trait::BEGIN@8
1115µs11µsClass::MOP::Class::Immutable::Trait::::BEGIN@39Class::MOP::Class::Immutable::Trait::BEGIN@39
1115µs16µsClass::MOP::Class::Immutable::Trait::::BEGIN@29Class::MOP::Class::Immutable::Trait::BEGIN@29
1114µs9µsClass::MOP::Class::Immutable::Trait::::BEGIN@5Class::MOP::Class::Immutable::Trait::BEGIN@5
1113µs3µ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;
21300nsour $VERSION = '2.1605';
3
4216µs214µs
# spent 12µs (10+2) within Class::MOP::Class::Immutable::Trait::BEGIN@4 which was called: # once (10µs+2µs) by Module::Runtime::require_module at line 4
use strict;
# spent 12µs making 1 call to Class::MOP::Class::Immutable::Trait::BEGIN@4 # spent 2µs making 1 call to strict::import
5214µs214µs
# spent 9µs (4+5) within Class::MOP::Class::Immutable::Trait::BEGIN@5 which was called: # once (4µs+5µs) by Module::Runtime::require_module at line 5
use warnings;
# spent 9µs making 1 call to Class::MOP::Class::Immutable::Trait::BEGIN@5 # spent 5µs making 1 call to warnings::import
6
7214µs13µs
# spent 3µs within Class::MOP::Class::Immutable::Trait::BEGIN@7 which was called: # once (3µs+0s) by Module::Runtime::require_module at line 7
use MRO::Compat;
# spent 3µs making 1 call to Class::MOP::Class::Immutable::Trait::BEGIN@7
8295µs229µs
# spent 17µs (6+12) within Class::MOP::Class::Immutable::Trait::BEGIN@8 which was called: # once (6µs+12µs) by Module::Runtime::require_module at line 8
use Module::Runtime 'use_module';
# spent 17µs making 1 call to Class::MOP::Class::Immutable::Trait::BEGIN@8 # spent 12µs making 1 call to Module::Runtime::import
9
10# the original class of the metaclass instance
112348µs
# spent 34µs within Class::MOP::Class::Immutable::Trait::_get_mutable_metaclass_name which was called 23 times, avg 1µs/call: # 23 times (34µs+0s) by Class::MOP::Class::_real_ref_name at line 122 of Class/MOP/Class.pm, avg 1µs/call
sub _get_mutable_metaclass_name { $_[0]{__immutable}{original_class} }
12
13sub is_mutable { 0 }
142326µ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
281500nsfor my $name (qw/superclasses/) {
29261µs227µs
# spent 16µs (5+11) within Class::MOP::Class::Immutable::Trait::BEGIN@29 which was called: # once (5µs+11µs) by Module::Runtime::require_module at line 29
no strict 'refs';
# spent 16µs making 1 call to Class::MOP::Class::Immutable::Trait::BEGIN@29 # spent 11µs making 1 call to strict::unimport
30 *{__PACKAGE__."::$name"} = sub {
31 my $orig = shift;
32 my $self = shift;
33 _immutable_read_only($name) if @_;
34 $self->$orig;
3514µs };
36}
37
381300nsfor my $name (qw/add_method alias_method remove_method add_attribute remove_attribute remove_package_symbol add_package_symbol/) {
392183µs217µs
# spent 11µs (5+6) within Class::MOP::Class::Immutable::Trait::BEGIN@39 which was called: # once (5µs+6µs) by Module::Runtime::require_module at line 39
no strict 'refs';
# spent 11µs making 1 call to Class::MOP::Class::Immutable::Trait::BEGIN@39 # spent 6µs making 1 call to strict::unimport
40714µs *{__PACKAGE__."::$name"} = sub { _immutable_cannot_call($name) };
41}
42
43sub class_precedence_list {
44 my $orig = shift;
45 my $self = shift;
46 @{ $self->{__immutable}{class_precedence_list}
47 ||= [ $self->$orig ] };
48}
49
50sub linearized_isa {
51679µs my $orig = shift;
52678µs my $self = shift;
5367124µs1671µs @{ $self->{__immutable}{linearized_isa} ||= [ $self->$orig ] };
# spent 71µs making 16 calls to Class::MOP::Class::linearized_isa, avg 4µ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 {
69419µs my $orig = shift;
70419µs my $self = shift;
714191µs16656µs @{ $self->{__immutable}{get_all_attributes} ||= [ $self->$orig ] };
# spent 656µs making 16 calls to Class::MOP::Class::get_all_attributes, avg 41µs/call
72}
73
74sub get_meta_instance {
7529630µs my $orig = shift;
7629629µs my $self = shift;
772964.49ms221.00ms $self->{__immutable}{get_meta_instance} ||= $self->$orig;
# spent 1.00ms making 22 calls to Class::MOP::Class::get_meta_instance, avg 46µs/call
78}
79
80sub _method_map {
8124627µs my $orig = shift;
8224628µs my $self = shift;
83246367µs2448µs $self->{__immutable}{_method_map} ||= $self->$orig;
# spent 47µs making 19 calls to Class::MOP::Mixin::HasMethods::_method_map, avg 2µs/call # spent 1µs making 5 calls to Class::MOP::Method::body, avg 260ns/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__