← Index
NYTProf Performance Profile   « block view • line view • sub view »
For mentat.storage.mongo.pl
  Run on Tue Jun 24 10:04:38 2014
Reported on Tue Jun 24 10:05:05 2014

Filename/usr/share/perl/5.14/base.pm
StatementsExecuted 2259 statements in 4.46ms
Subroutines
Calls P F Exclusive
Time
Inclusive
Time
Subroutine
64646110.6ms23.5msbase::::importbase::import (recurses: max depth 2, inclusive time 6.99ms)
7611448µs448µsbase::::has_versionbase::has_version
7611203µs203µsbase::::has_fieldsbase::has_fields
7611149µs149µsbase::::has_attrbase::has_attr
11112µs22µsbase::::BEGIN@3base::BEGIN@3
1115µs23µsbase::::BEGIN@4base::BEGIN@4
0000s0sbase::::__ANON__[:53]base::__ANON__[:53]
0000s0sbase::::__ANON__[:60]base::__ANON__[:60]
0000s0sbase::::get_attrbase::get_attr
0000s0sbase::::inherit_fieldsbase::inherit_fields
Call graph for these subroutines as a Graphviz dot language file.
Line State
ments
Time
on line
Calls Time
in subs
Code
1package base;
2
3224µs232µs
# spent 22µs (12+10) within base::BEGIN@3 which was called: # once (12µs+10µs) by Try::Tiny::BEGIN@14 at line 3
use strict 'vars';
# spent 22µs making 1 call to base::BEGIN@3 # spent 10µs making 1 call to strict::import
42828µs240µs
# spent 23µs (5+17) within base::BEGIN@4 which was called: # once (5µs+17µs) by Try::Tiny::BEGIN@14 at line 4
use vars qw($VERSION);
# spent 23µs making 1 call to base::BEGIN@4 # spent 17µs making 1 call to vars::import
51600ns$VERSION = '2.16';
6113µs$VERSION = eval $VERSION;
# spent 2µs executing statements in string eval
7
8# constant.pm is slow
9sub SUCCESS () { 1 }
10
11sub PUBLIC () { 2**0 }
12sub PRIVATE () { 2**1 }
13sub INHERITED () { 2**2 }
14sub PROTECTED () { 2**3 }
15
161700nsmy $Fattr = \%fields::attr;
17
18
# spent 203µs within base::has_fields which was called 76 times, avg 3µs/call: # 76 times (203µs+0s) by base::import at line 112, avg 3µs/call
sub has_fields {
19304265µs my($base) = shift;
20 my $fglob = ${"$base\::"}{FIELDS};
21 return( ($fglob && 'GLOB' eq ref($fglob) && *$fglob{HASH}) ? 1 : 0 );
22}
23
24
# spent 448µs within base::has_version which was called 76 times, avg 6µs/call: # 76 times (448µs+0s) by base::import at line 82, avg 6µs/call
sub has_version {
25304518µs my($base) = shift;
26 my $vglob = ${$base.'::'}{VERSION};
27 return( ($vglob && *$vglob{SCALAR}) ? 1 : 0 );
28}
29
30
# spent 149µs within base::has_attr which was called 76 times, avg 2µs/call: # 76 times (149µs+0s) by base::import at line 112, avg 2µs/call
sub has_attr {
31228192µs my($proto) = shift;
32 my($class) = ref $proto || $proto;
33 return exists $Fattr->{$class};
34}
35
36sub get_attr {
37 $Fattr->{$_[0]} = [1] unless $Fattr->{$_[0]};
38 return $Fattr->{$_[0]};
39}
40
411900nsif ($] < 5.009) {
42 *get_fields = sub {
43 # Shut up a possible typo warning.
44 () = \%{$_[0].'::FIELDS'};
45 my $f = \%{$_[0].'::FIELDS'};
46
47 # should be centralized in fields? perhaps
48 # fields::mk_FIELDS_be_OK. Peh. As long as %{ $package . '::FIELDS' }
49 # is used here anyway, it doesn't matter.
50 bless $f, 'pseudohash' if (ref($f) ne 'pseudohash');
51
52 return $f;
53 }
54}
55else {
56 *get_fields = sub {
57 # Shut up a possible typo warning.
58 () = \%{$_[0].'::FIELDS'};
59 return \%{$_[0].'::FIELDS'};
60 }
6113µs}
62
63
# spent 23.5ms (10.6+12.9) within base::import which was called 64 times, avg 368µs/call: # once (576µs+5.50ms) by Moose::Meta::Attribute::BEGIN@27 at line 27 of Moose/Meta/Attribute.pm # once (569µs+4.13ms) by Class::MOP::Class::BEGIN@26 at line 26 of Class/MOP/Class.pm # once (1.54ms+2.09ms) by DateTime::Locale::en_US::BEGIN@25 at line 25 of DateTime/Locale/en_US.pm # once (468µs+1.82ms) by Moose::Meta::Method::Overridden::BEGIN@12 at line 12 of Moose/Meta/Method/Overridden.pm # once (463µs+1.48ms) by Class::MOP::Method::Accessor::BEGIN@17 at line 17 of Class/MOP/Method/Accessor.pm # once (773µs+806µs) by Class::MOP::Method::Meta::BEGIN@18 at line 18 of Class/MOP/Method/Meta.pm # once (566µs+189µs) by Class::MOP::Method::Constructor::BEGIN@17 at line 17 of Class/MOP/Method/Constructor.pm # once (259µs+95µs) by Class::MOP::Mixin::AttributeCore::BEGIN@14 at line 14 of Class/MOP/Mixin/AttributeCore.pm # once (58µs+37µs) by Moose::Meta::Role::BEGIN@27 at line 27 of Moose/Meta/Role.pm # once (44µs+28µs) by Moose::Meta::Role::Attribute::BEGIN@16 at line 16 of Moose/Meta/Role/Attribute.pm # once (44µs+23µs) by Moose::Meta::Method::Constructor::BEGIN@18 at line 18 of Moose/Meta/Method/Constructor.pm # once (45µs+23µs) by Moose::Meta::Method::Destructor::BEGIN@17 at line 17 of Moose/Meta/Method/Destructor.pm # once (43µs+24µs) by Moose::Meta::Method::Accessor::BEGIN@15 at line 15 of Moose/Meta/Method/Accessor.pm # once (43µs+23µs) by Class::MOP::Attribute::BEGIN@19 at line 19 of Class/MOP/Attribute.pm # once (43µs+23µs) by Moose::Meta::Method::Delegation::BEGIN@16 at line 16 of Moose/Meta/Method/Delegation.pm # once (40µs+23µs) by Moose::Meta::Method::Meta::BEGIN@13 at line 13 of Moose/Meta/Method/Meta.pm # once (38µs+17µs) by Moose::Meta::Class::Immutable::Trait::BEGIN@15 at line 15 of Moose/Meta/Class/Immutable/Trait.pm # once (42µs+13µs) by Moose::Meta::Role::Method::Conflicting::BEGIN@15 at line 15 of Moose/Meta/Role/Method/Conflicting.pm # once (37µs+17µs) by JSON::BEGIN@6 at line 6 of JSON.pm # once (41µs+13µs) by Moose::Meta::TypeConstraint::Parameterized::BEGIN@17 at line 17 of Moose/Meta/TypeConstraint/Parameterized.pm # once (31µs+17µs) by Moose::Meta::Role::Composite::BEGIN@16 at line 16 of Moose/Meta/Role/Composite.pm # once (35µs+12µs) by Class::MOP::Method::Wrapped::BEGIN@16 at line 16 of Class/MOP/Method/Wrapped.pm # once (34µs+12µs) by Try::Tiny::BEGIN@14 at line 14 of Try/Tiny.pm # once (31µs+15µs) by DateTime::Infinite::Future::BEGIN@47 at line 47 of DateTime/Infinite.pm # once (31µs+14µs) by boolean::BEGIN@14 at line 14 of boolean.pm # once (32µs+13µs) by Encode::BEGIN@13 at line 13 of Encode.pm # once (28µs+17µs) by Moose::Meta::Role::Method::Required::BEGIN@17 at line 17 of Moose/Meta/Role/Method/Required.pm # once (29µs+16µs) by Moose::Meta::TypeCoercion::Union::BEGIN@16 at line 16 of Moose/Meta/TypeCoercion/Union.pm # once (31µs+13µs) by Moose::Meta::Role::Method::BEGIN@13 at line 13 of Moose/Meta/Role/Method.pm # once (31µs+13µs) by Moose::Meta::Class::BEGIN@31 at line 31 of Moose/Meta/Class.pm # once (31µs+11µs) by Moose::Meta::TypeConstraint::Class::BEGIN@17 at line 17 of Moose/Meta/TypeConstraint/Class.pm # once (29µs+14µs) by Moose::Meta::Instance::BEGIN@15 at line 15 of Moose/Meta/Instance.pm # once (29µs+13µs) by DateTime::Infinite::BEGIN@12 at line 12 of DateTime/Infinite.pm # once (30µs+12µs) by Moose::Meta::Method::Augmented::BEGIN@12 at line 12 of Moose/Meta/Method/Augmented.pm # once (30µs+11µs) by Encode::Alias::BEGIN@8 at line 8 of Encode/Alias.pm # once (29µs+12µs) by Class::MOP::Method::Overload::BEGIN@15 at line 15 of Class/MOP/Method/Overload.pm # once (29µs+12µs) by Class::MOP::Instance::BEGIN@15 at line 15 of Class/MOP/Instance.pm # once (27µs+13µs) by Moose::Error::Default::BEGIN@17 at line 17 of Moose/Error/Default.pm # once (28µs+12µs) by Class::MOP::Mixin::HasAttributes::BEGIN@15 at line 15 of Class/MOP/Mixin/HasAttributes.pm # once (28µs+12µs) by Moose::Meta::Role::Application::RoleSummation::BEGIN@17 at line 17 of Moose/Meta/Role/Application/RoleSummation.pm # once (28µs+12µs) by Moose::Meta::Role::Application::ToRole::BEGIN@15 at line 15 of Moose/Meta/Role/Application/ToRole.pm # once (28µs+12µs) by Class::Load::BEGIN@7 at line 7 of Class/Load.pm # once (28µs+12µs) by Moose::Meta::TypeConstraint::Parameterizable::BEGIN@13 at line 13 of Moose/Meta/TypeConstraint/Parameterizable.pm # once (27µs+13µs) by Moose::Meta::TypeConstraint::Registry::BEGIN@16 at line 16 of Moose/Meta/TypeConstraint/Registry.pm # once (28µs+12µs) by Class::MOP::Mixin::HasMethods::BEGIN@21 at line 21 of Class/MOP/Mixin/HasMethods.pm # once (27µs+12µs) by Moose::Meta::TypeConstraint::Role::BEGIN@17 at line 17 of Moose/Meta/TypeConstraint/Role.pm # once (28µs+12µs) by Moose::Meta::Role::Application::ToInstance::BEGIN@16 at line 16 of Moose/Meta/Role/Application/ToInstance.pm # once (27µs+12µs) by DateTime::Infinite::Past::BEGIN@75 at line 75 of DateTime/Infinite.pm # once (27µs+12µs) by Moose::Meta::TypeConstraint::DuckType::BEGIN@20 at line 20 of Moose/Meta/TypeConstraint/DuckType.pm # once (27µs+12µs) by Moose::Meta::TypeConstraint::Enum::BEGIN@16 at line 16 of Moose/Meta/TypeConstraint/Enum.pm # once (26µs+12µs) by Moose::Meta::TypeConstraint::BEGIN@26 at line 26 of Moose/Meta/TypeConstraint.pm # once (26µs+12µs) by Moose::Meta::Role::Application::ToClass::BEGIN@17 at line 17 of Moose/Meta/Role/Application/ToClass.pm # once (27µs+11µs) by Moose::Meta::TypeConstraint::Union::BEGIN@19 at line 19 of Moose/Meta/TypeConstraint/Union.pm # once (26µs+12µs) by Sub::Name::BEGIN@49 at line 49 of Sub/Name.pm # once (21µs+11µs) by Sub::Name::BEGIN@50 at line 50 of Sub/Name.pm # once (1.90ms+-1.90ms) by DateTime::Locale::en::BEGIN@25 at line 25 of DateTime/Locale/en.pm # once (29µs+-29µs) by Class::MOP::Method::Generated::BEGIN@16 at line 16 of Class/MOP/Method/Generated.pm # once (44µs+-44µs) by Class::MOP::Method::Inlined::BEGIN@15 at line 15 of Class/MOP/Method/Inlined.pm # once (549µs+-549µs) by Class::MOP::Method::BEGIN@16 at line 16 of Class/MOP/Method.pm # once (1.21ms+-1.21ms) by Class::MOP::Module::BEGIN@16 at line 16 of Class/MOP/Module.pm # once (33µs+-33µs) by Moose::Meta::Method::BEGIN@14 at line 14 of Moose/Meta/Method.pm # once (33µs+-33µs) by Class::MOP::Package::BEGIN@18 at line 18 of Class/MOP/Package.pm # once (68µs+-68µs) by DateTime::Locale::root::BEGIN@25 at line 25 of DateTime/Locale/root.pm # once (32µs+-32µs) by Moose::Meta::Mixin::AttributeCore::BEGIN@12 at line 12 of Moose/Meta/Mixin/AttributeCore.pm
sub import {
6414132.61ms my $class = shift;
65
66 return SUCCESS unless @_;
67
68 # List of base classes from which we will inherit %FIELDS.
69 my $fields_base;
70
71 my $inheritor = caller(0);
72 my @isa_classes;
73
74 my @bases;
75 foreach my $base (@_) {
76 if ( $inheritor eq $base ) {
77 warn "Class '$inheritor' tried to inherit from itself\n";
78 }
79
8090159µs next if grep $_->isa($base), ($inheritor, @bases);
# spent 159µs making 90 calls to UNIVERSAL::isa, avg 2µs/call
81
8276448µs if (has_version($base)) {
# spent 448µs making 76 calls to base::has_version, avg 6µs/call
83 ${$base.'::VERSION'} = '-1, set by base.pm'
84 unless defined ${$base.'::VERSION'};
85 }
86 else {
87 my $sigdie;
88 {
89 local $SIG{__DIE__};
90 eval "require $base";
# spent 81µs executing statements in string eval # spent 80µs executing statements in string eval # spent 80µs executing statements in string eval # spent 78µs executing statements in string eval # spent 76µs executing statements in string eval # spent 70µs executing statements in string eval # spent 68µs executing statements in string eval # spent 68µs executing statements in string eval # spent 66µs executing statements in string eval # spent 66µs executing statements in string eval # spent 64µs executing statements in string eval # spent 2µs executing statements in string eval
91 # Only ignore "Can't locate" errors from our eval require.
92 # Other fatal errors (syntax etc) must be reported.
93 die if $@ && $@ !~ /^Can't locate .*? at \(eval /;
94 unless (%{"$base\::"}) {
95 require Carp;
96 local $" = " ";
97 Carp::croak(<<ERROR);
98Base class package "$base" is empty.
99 (Perhaps you need to 'use' the module which defines that package first,
100 or make that module available in \@INC (\@INC contains: @INC).
101ERROR
102 }
103 $sigdie = $SIG{__DIE__} || undef;
104 }
105 # Make sure a global $SIG{__DIE__} makes it out of the localization.
106 $SIG{__DIE__} = $sigdie if defined $sigdie;
107 ${$base.'::VERSION'} = "-1, set by base.pm"
108 unless defined ${$base.'::VERSION'};
109 }
110 push @bases, $base;
111
112152352µs if ( has_fields($base) || has_attr($base) ) {
# spent 203µs making 76 calls to base::has_fields, avg 3µs/call # spent 149µs making 76 calls to base::has_attr, avg 2µs/call
113 # No multiple fields inheritance *suck*
114 if ($fields_base) {
115 require Carp;
116 Carp::croak("Can't multiply inherit fields");
117 } else {
118 $fields_base = $base;
119 }
120 }
121 }
122 # Save this until the end so it's all or nothing if the above loop croaks.
123 push @{"$inheritor\::ISA"}, @isa_classes;
124
125 push @{"$inheritor\::ISA"}, @bases;
126
127 if( defined $fields_base ) {
128 inherit_fields($inheritor, $fields_base);
129 }
130}
131
132sub inherit_fields {
133 my($derived, $base) = @_;
134
135 return SUCCESS unless $base;
136
137 my $battr = get_attr($base);
138 my $dattr = get_attr($derived);
139 my $dfields = get_fields($derived);
140 my $bfields = get_fields($base);
141
142 $dattr->[0] = @$battr;
143
144 if( keys %$dfields ) {
145 warn <<"END";
146$derived is inheriting from $base but already has its own fields!
147This will cause problems. Be sure you use base BEFORE declaring fields.
148END
149
150 }
151
152 # Iterate through the base's fields adding all the non-private
153 # ones to the derived class. Hang on to the original attribute
154 # (Public, Private, etc...) and add Inherited.
155 # This is all too complicated to do efficiently with add_fields().
156 while (my($k,$v) = each %$bfields) {
157 my $fno;
158 if ($fno = $dfields->{$k} and $fno != $v) {
159 require Carp;
160 Carp::croak ("Inherited fields can't override existing fields");
161 }
162
163 if( $battr->[$v] & PRIVATE ) {
164 $dattr->[$v] = PRIVATE | INHERITED;
165 }
166 else {
167 $dattr->[$v] = INHERITED | $battr->[$v];
168 $dfields->{$k} = $v;
169 }
170 }
171
172 foreach my $idx (1..$#{$battr}) {
173 next if defined $dattr->[$idx];
174 $dattr->[$idx] = $battr->[$idx] & INHERITED;
175 }
176}
177
17814µs1;
179
180__END__