Filename | /2home/ss5/perl5/perlbrew/perls/perl-5.12.3/lib/5.12.3/base.pm |
Statements | Executed 3749 statements in 11.0ms |
Calls | P | F | Exclusive Time |
Inclusive Time |
Subroutine |
---|---|---|---|---|---|
127 | 127 | 117 | 43.5ms | 126ms | import (recurses: max depth 2, inclusive time 30.5ms) | base::
143 | 1 | 1 | 587µs | 587µs | has_fields | base::
143 | 1 | 1 | 402µs | 402µs | has_attr | base::
1 | 1 | 1 | 327µs | 648µs | BEGIN@4 | base::
1 | 1 | 1 | 11µs | 21µs | BEGIN@3 | base::
0 | 0 | 0 | 0s | 0s | __ANON__[:48] | base::
0 | 0 | 0 | 0s | 0s | __ANON__[:55] | base::
0 | 0 | 0 | 0s | 0s | get_attr | base::
0 | 0 | 0 | 0s | 0s | inherit_fields | base::
Line | State ments |
Time on line |
Calls | Time in subs |
Code |
---|---|---|---|---|---|
1 | package base; | ||||
2 | |||||
3 | 3 | 20µs | 2 | 31µs | # spent 21µs (11+10) within base::BEGIN@3 which was called:
# once (11µs+10µs) by Class::Load::BEGIN@7 at line 3 # spent 21µs making 1 call to base::BEGIN@3
# spent 10µs making 1 call to strict::import |
4 | 3 | 748µs | 2 | 673µs | # spent 648µs (327+321) within base::BEGIN@4 which was called:
# once (327µs+321µs) by Class::Load::BEGIN@7 at line 4 # spent 648µs making 1 call to base::BEGIN@4
# spent 25µs making 1 call to vars::import |
5 | 1 | 400ns | $VERSION = '2.18'; | ||
6 | 1 | 13µs | $VERSION = eval $VERSION; # spent 2µs executing statements in string eval | ||
7 | |||||
8 | # constant.pm is slow | ||||
9 | sub SUCCESS () { 1 } | ||||
10 | |||||
11 | sub PUBLIC () { 2**0 } | ||||
12 | sub PRIVATE () { 2**1 } | ||||
13 | sub INHERITED () { 2**2 } | ||||
14 | sub PROTECTED () { 2**3 } | ||||
15 | |||||
16 | |||||
17 | 1 | 600ns | my $Fattr = \%fields::attr; | ||
18 | |||||
19 | # spent 587µs within base::has_fields which was called 143 times, avg 4µs/call:
# 143 times (587µs+0s) by base::import at line 101, avg 4µs/call | ||||
20 | 429 | 708µs | my($base) = shift; | ||
21 | my $fglob = ${"$base\::"}{FIELDS}; | ||||
22 | return( ($fglob && 'GLOB' eq ref($fglob) && *$fglob{HASH}) ? 1 : 0 ); | ||||
23 | } | ||||
24 | |||||
25 | # spent 402µs within base::has_attr which was called 143 times, avg 3µs/call:
# 143 times (402µs+0s) by base::import at line 101, avg 3µs/call | ||||
26 | 429 | 476µs | my($proto) = shift; | ||
27 | my($class) = ref $proto || $proto; | ||||
28 | return exists $Fattr->{$class}; | ||||
29 | } | ||||
30 | |||||
31 | sub get_attr { | ||||
32 | $Fattr->{$_[0]} = [1] unless $Fattr->{$_[0]}; | ||||
33 | return $Fattr->{$_[0]}; | ||||
34 | } | ||||
35 | |||||
36 | 2 | 4µs | if ($] < 5.009) { | ||
37 | *get_fields = sub { | ||||
38 | # Shut up a possible typo warning. | ||||
39 | () = \%{$_[0].'::FIELDS'}; | ||||
40 | my $f = \%{$_[0].'::FIELDS'}; | ||||
41 | |||||
42 | # should be centralized in fields? perhaps | ||||
43 | # fields::mk_FIELDS_be_OK. Peh. As long as %{ $package . '::FIELDS' } | ||||
44 | # is used here anyway, it doesn't matter. | ||||
45 | bless $f, 'pseudohash' if (ref($f) ne 'pseudohash'); | ||||
46 | |||||
47 | return $f; | ||||
48 | } | ||||
49 | } | ||||
50 | else { | ||||
51 | *get_fields = sub { | ||||
52 | # Shut up a possible typo warning. | ||||
53 | () = \%{$_[0].'::FIELDS'}; | ||||
54 | return \%{$_[0].'::FIELDS'}; | ||||
55 | } | ||||
56 | } | ||||
57 | |||||
58 | # spent 126ms (43.5+82.9) within base::import which was called 127 times, avg 995µs/call:
# once (711µs+53.1ms) by Tapper::MCP::Scheduler::Controller::BEGIN@7 at line 7 of lib/Tapper/MCP/Scheduler/Controller.pm
# once (2.30ms+10.5ms) by DBIx::Class::SQLMaker::SQLite::BEGIN@4 at line 4 of DBIx/Class/SQLMaker/SQLite.pm
# once (2.58ms+6.15ms) by DBIx::Class::Storage::DBI::BEGIN@7 at line 7 of DBIx/Class/Storage/DBI.pm
# once (830µs+6.57ms) by DBIx::Class::BEGIN@70 at line 70 of DBIx/Class.pm
# once (540µs+5.99ms) by Class::MOP::Class::BEGIN@26 at line 26 of Class/MOP/Class.pm
# once (635µs+5.18ms) by Moose::Meta::Attribute::BEGIN@27 at line 27 of Moose/Meta/Attribute.pm
# once (4.35ms+1.27ms) by DBIx::Class::InflateColumn::BEGIN@6 at line 6 of DBIx/Class/InflateColumn.pm
# once (425µs+4.18ms) by Class::MOP::Method::Accessor::BEGIN@17 at line 17 of Class/MOP/Method/Accessor.pm
# once (1.33ms+1.83ms) by DateTime::Locale::en_US::BEGIN@25 at line 25 of DateTime/Locale/en_US.pm
# once (388µs+2.19ms) by Moose::Meta::Method::Overridden::BEGIN@12 at line 12 of Moose/Meta/Method/Overridden.pm
# once (556µs+1.32ms) by Object::Enum::BEGIN@10 at line 10 of Object/Enum.pm
# once (737µs+787µs) by Class::MOP::Method::Meta::BEGIN@18 at line 18 of Class/MOP/Method/Meta.pm
# once (572µs+914µs) by SQL::Translator::Schema::Procedure::BEGIN@51 at line 51 of SQL/Translator/Schema/Procedure.pm
# once (642µs+793µs) by DBIx::Class::ResultSourceProxy::Table::BEGIN@6 at line 6 of DBIx/Class/ResultSourceProxy/Table.pm
# once (1.01ms+94µs) by SQL::Translator::BEGIN@23 at line 23 of SQL/Translator.pm
# once (514µs+204µs) by Class::MOP::Method::Constructor::BEGIN@17 at line 17 of Class/MOP/Method/Constructor.pm
# once (280µs+118µs) by DBIx::Class::Storage::DBI::Cursor::BEGIN@6 at line 6 of DBIx/Class/Storage/DBI/Cursor.pm
# once (216µs+75µs) by Class::MOP::Mixin::AttributeCore::BEGIN@14 at line 14 of Class/MOP/Mixin/AttributeCore.pm
# once (177µs+23µs) by Hash::Merge::BEGIN@7 at line 7 of Hash/Merge.pm
# once (137µs+28µs) by Moose::Meta::Role::BEGIN@27 at line 27 of Moose/Meta/Role.pm
# once (138µs+13µs) by DBIx::Class::Version::Table::BEGIN@3 at line 3 of DBIx/Class/Schema/Versioned.pm
# once (106µs+23µs) by Moose::Meta::Method::Accessor::BEGIN@15 at line 15 of Moose/Meta/Method/Accessor.pm
# once (112µs+14µs) by Moose::Meta::Method::Destructor::BEGIN@17 at line 17 of Moose/Meta/Method/Destructor.pm
# once (104µs+21µs) by Class::MOP::Attribute::BEGIN@19 at line 19 of Class/MOP/Attribute.pm
# once (101µs+22µs) by Moose::Meta::Role::Attribute::BEGIN@16 at line 16 of Moose/Meta/Role/Attribute.pm
# once (92µs+18µs) by File::Temp::BEGIN@162 at line 162 of File/Temp.pm
# once (88µs+15µs) by Moose::Meta::Method::Constructor::BEGIN@18 at line 18 of Moose/Meta/Method/Constructor.pm
# once (81µs+15µs) by Moose::Meta::Method::Meta::BEGIN@13 at line 13 of Moose/Meta/Method/Meta.pm
# once (86µs+10µs) by Moose::Meta::TypeConstraint::Class::BEGIN@17 at line 17 of Moose/Meta/TypeConstraint/Class.pm
# once (86µs+10µs) by DBIx::Class::Relationship::BEGIN@6 at line 6 of DBIx/Class/Relationship.pm
# once (84µs+11µs) by DBIx::Class::ResultSource::Table::BEGIN@8 at line 8 of DBIx/Class/ResultSource/Table.pm
# once (83µs+11µs) by DBIx::Class::Storage::DBI::SQLite::BEGIN@6 at line 6 of DBIx/Class/Storage/DBI/SQLite.pm
# once (79µs+15µs) by Moose::Meta::Method::Delegation::BEGIN@16 at line 16 of Moose/Meta/Method/Delegation.pm
# once (80µs+12µs) by SQL::Translator::Schema::Constants::BEGIN@61 at line 61 of SQL/Translator/Schema/Constants.pm
# once (77µs+10µs) by Moose::Meta::Role::Composite::BEGIN@16 at line 16 of Moose/Meta/Role/Composite.pm
# once (75µs+11µs) by Moose::Meta::Class::BEGIN@31 at line 31 of Moose/Meta/Class.pm
# once (73µs+12µs) by DBIx::Class::FilterColumn::BEGIN@5 at line 5 of DBIx/Class/FilterColumn.pm
# once (70µs+15µs) by Devel::Backtrace::Point::BEGIN@25 at line 25 of Devel/Backtrace/Point.pm
# once (71µs+12µs) by DateTime::Infinite::BEGIN@12 at line 12 of DateTime/Infinite.pm
# once (72µs+11µs) by Variable::Magic::BEGIN@605 at line 605 of Variable/Magic.pm
# once (72µs+11µs) by DBIx::Class::Schema::BEGIN@14 at line 14 of DBIx/Class/Schema.pm
# once (70µs+11µs) by DBIx::Class::Relationship::ProxyMethods::BEGIN@7 at line 7 of DBIx/Class/Relationship/ProxyMethods.pm
# once (68µs+11µs) by DBIx::Class::InflateColumn::DateTime::BEGIN@5 at line 5 of DBIx/Class/InflateColumn/DateTime.pm
# once (68µs+11µs) by SQL::Translator::Schema::Trigger::BEGIN@51 at line 51 of SQL/Translator/Schema/Trigger.pm
# once (69µs+10µs) by DBIx::Class::Core::BEGIN@6 at line 6 of DBIx/Class/Core.pm
# once (69µs+10µs) by Moose::Meta::TypeConstraint::Parameterizable::BEGIN@13 at line 13 of Moose/Meta/TypeConstraint/Parameterizable.pm
# once (69µs+10µs) by Moose::Meta::TypeConstraint::Registry::BEGIN@16 at line 16 of Moose/Meta/TypeConstraint/Registry.pm
# once (68µs+11µs) by Moose::Meta::Role::Application::RoleSummation::BEGIN@17 at line 17 of Moose/Meta/Role/Application/RoleSummation.pm
# once (68µs+11µs) by Moose::Meta::Role::Method::BEGIN@13 at line 13 of Moose/Meta/Role/Method.pm
# once (67µs+11µs) by Moose::Meta::Instance::BEGIN@15 at line 15 of Moose/Meta/Instance.pm
# once (66µs+12µs) by DateTime::Format::Builder::Parser::Quick::BEGIN@5 at line 5 of DateTime/Format/Builder/Parser/Quick.pm
# once (66µs+11µs) by SQL::Translator::Parser::DBIx::Class::BEGIN@23 at line 23 of SQL/Translator/Parser/DBIx/Class.pm
# once (66µs+10µs) by Moose::Meta::TypeConstraint::DuckType::BEGIN@20 at line 20 of Moose/Meta/TypeConstraint/DuckType.pm
# once (66µs+10µs) by DBIx::Class::ResultSource::View::BEGIN@8 at line 8 of DBIx/Class/ResultSource/View.pm
# once (65µs+11µs) by Moose::Meta::Role::Application::ToRole::BEGIN@15 at line 15 of Moose/Meta/Role/Application/ToRole.pm
# once (64µs+11µs) by Moose::Meta::Role::Application::ToClass::BEGIN@17 at line 17 of Moose/Meta/Role/Application/ToClass.pm
# once (64µs+11µs) by SQL::Translator::Schema::Index::BEGIN@50 at line 50 of SQL/Translator/Schema/Index.pm
# once (64µs+11µs) by Moose::Meta::TypeConstraint::BEGIN@26 at line 26 of Moose/Meta/TypeConstraint.pm
# once (62µs+12µs) by Moose::Meta::Class::Immutable::Trait::BEGIN@15 at line 15 of Moose/Meta/Class/Immutable/Trait.pm
# once (65µs+10µs) by Moose::Meta::TypeConstraint::Role::BEGIN@17 at line 17 of Moose/Meta/TypeConstraint/Role.pm
# once (62µs+11µs) by Test::Fixture::DBIC::Schema::BEGIN@5 at line 5 of Test/Fixture/DBIC/Schema.pm
# once (62µs+10µs) by Moose::Meta::Role::Method::Conflicting::BEGIN@15 at line 15 of Moose/Meta/Role/Method/Conflicting.pm
# once (62µs+9µs) by Moose::Meta::TypeConstraint::Enum::BEGIN@16 at line 16 of Moose/Meta/TypeConstraint/Enum.pm
# once (62µs+10µs) by Moose::Meta::TypeConstraint::Parameterized::BEGIN@17 at line 17 of Moose/Meta/TypeConstraint/Parameterized.pm
# once (63µs+8µs) by DBIx::Class::ResultSource::BEGIN@16 at line 16 of DBIx/Class/ResultSource.pm
# once (61µs+10µs) by Kwalify::BEGIN@18 at line 18 of Kwalify.pm
# once (62µs+8µs) by Class::Load::BEGIN@7 at line 7 of Class/Load.pm
# once (60µs+10µs) by Moose::Meta::TypeCoercion::Union::BEGIN@16 at line 16 of Moose/Meta/TypeCoercion/Union.pm
# once (59µs+10µs) by Moose::Meta::Role::Application::ToInstance::BEGIN@16 at line 16 of Moose/Meta/Role/Application/ToInstance.pm
# once (60µs+9µs) by SQL::Translator::Schema::Field::BEGIN@47 at line 47 of SQL/Translator/Schema/Field.pm
# once (62µs+7µs) by DBIx::Class::PK::Auto::BEGIN@4 at line 4 of DBIx/Class/PK/Auto.pm
# once (56µs+12µs) by Moose::Meta::Method::Augmented::BEGIN@12 at line 12 of Moose/Meta/Method/Augmented.pm
# once (58µs+9µs) by Moose::Meta::Role::Method::Required::BEGIN@17 at line 17 of Moose/Meta/Role/Method/Required.pm
# once (59µs+8µs) by SQL::Translator::Schema::Constraint::BEGIN@48 at line 48 of SQL/Translator/Schema/Constraint.pm
# once (55µs+8µs) by SQL::Translator::Schema::View::BEGIN@47 at line 47 of SQL/Translator/Schema/View.pm
# once (54µs+8µs) by Class::MOP::Instance::BEGIN@15 at line 15 of Class/MOP/Instance.pm
# once (52µs+9µs) by Class::MOP::Method::Wrapped::BEGIN@16 at line 16 of Class/MOP/Method/Wrapped.pm
# once (52µs+8µs) by Class::MOP::Method::Overload::BEGIN@15 at line 15 of Class/MOP/Method/Overload.pm
# once (52µs+6µs) by Sub::Name::BEGIN@49 at line 49 of Sub/Name.pm
# once (52µs+6µs) by DBIx::Class::ResultSet::BEGIN@5 at line 5 of DBIx/Class/ResultSet.pm
# once (52µs+6µs) by DBIx::Class::Relationship::Base::BEGIN@6 at line 6 of DBIx/Class/Relationship/Base.pm
# once (52µs+6µs) by DBIx::Class::ResultSetColumn::BEGIN@6 at line 6 of DBIx/Class/ResultSetColumn.pm
# once (51µs+6µs) by DBIx::Class::Version::TableCompat::BEGIN@33 at line 33 of DBIx/Class/Schema/Versioned.pm
# once (50µs+6µs) by DBIx::Class::TimeStamp::BEGIN@3 at line 3 of DBIx/Class/TimeStamp.pm
# once (48µs+6µs) by DBIx::Class::DynamicDefault::BEGIN@6 at line 6 of DBIx/Class/DynamicDefault.pm
# once (46µs+7µs) by Moose::Error::Default::BEGIN@17 at line 17 of Moose/Error/Default.pm
# once (47µs+6µs) by DBIx::Class::ResultSourceHandle::BEGIN@6 at line 6 of DBIx/Class/ResultSourceHandle.pm
# once (46µs+7µs) by SQL::Translator::Schema::Table::BEGIN@48 at line 48 of SQL/Translator/Schema/Table.pm
# once (46µs+6µs) by DBIx::Class::Schema::Versioned::BEGIN@202 at line 202 of DBIx/Class/Schema/Versioned.pm
# once (46µs+6µs) by DBIx::Class::Relationship::Helpers::BEGIN@7 at line 7 of DBIx/Class/Relationship/Helpers.pm
# once (45µs+7µs) by SQL::Translator::Schema::BEGIN@56 at line 56 of SQL/Translator/Schema.pm
# once (45µs+6µs) by DBIx::Class::PK::BEGIN@6 at line 6 of DBIx/Class/PK.pm
# once (45µs+6µs) by DBIx::Class::Version::BEGIN@48 at line 48 of DBIx/Class/Schema/Versioned.pm
# once (44µs+7µs) by Class::MOP::Mixin::HasMethods::BEGIN@21 at line 21 of Class/MOP/Mixin/HasMethods.pm
# once (43µs+7µs) by Moose::Meta::TypeConstraint::Union::BEGIN@19 at line 19 of Moose/Meta/TypeConstraint/Union.pm
# once (44µs+7µs) by SQL::Translator::Utils::BEGIN@22 at line 22 of SQL/Translator/Utils.pm
# once (44µs+5µs) by DateTime::Infinite::Future::BEGIN@44 at line 44 of DateTime/Infinite.pm
# once (44µs+6µs) by DateTime::Infinite::Past::BEGIN@68 at line 68 of DateTime/Infinite.pm
# once (43µs+6µs) by Class::MOP::Mixin::HasAttributes::BEGIN@15 at line 15 of Class/MOP/Mixin/HasAttributes.pm
# once (41µs+6µs) by DBIx::Class::VersionCompat::BEGIN@56 at line 56 of DBIx/Class/Schema/Versioned.pm
# once (37µs+6µs) by Sub::Name::BEGIN@50 at line 50 of Sub/Name.pm
# once (10µs+1µs) by File::Temp::BEGIN@173 at line 173 of File/Temp.pm
# once (60µs+-60µs) by DBIx::Class::Storage::BEGIN@6 at line 6 of DBIx/Class/Storage.pm
# once (43µs+-43µs) by DBIx::Class::Storage::NESTED_ROLLBACK_EXCEPTION::BEGIN@12 at line 12 of DBIx/Class/Storage.pm
# once (2.26ms+-2.26ms) by DBIx::Class::AccessorGroup::BEGIN@6 at line 6 of DBIx/Class/AccessorGroup.pm
# once (1.14ms+-1.14ms) by Class::Accessor::Fast::BEGIN@2 at line 2 of Class/Accessor/Fast.pm
# once (64µs+-64µs) by Log::Log4perl::Filter::Boolean::BEGIN@15 at line 15 of Log/Log4perl/Filter/Boolean.pm
# once (53µs+-53µs) by DateTime::Locale::root::BEGIN@25 at line 25 of DateTime/Locale/root.pm
# once (66µs+-66µs) by DBIx::Class::Cursor::BEGIN@6 at line 6 of DBIx/Class/Cursor.pm
# once (910µs+-910µs) by DBIx::Class::Componentised::BEGIN@7 at line 7 of DBIx/Class/Componentised.pm
# once (1.67ms+-1.67ms) by DateTime::Locale::en::BEGIN@25 at line 25 of DateTime/Locale/en.pm
# once (2.03ms+-2.03ms) by DBIx::Class::Storage::DBIHacks::BEGIN@13 at line 13 of DBIx/Class/Storage/DBIHacks.pm
# once (65µs+-65µs) by Class::MOP::Package::BEGIN@18 at line 18 of Class/MOP/Package.pm
# once (8.68ms+-8.68ms) by DBIx::Class::SQLMaker::BEGIN@38 at line 38 of DBIx/Class/SQLMaker.pm
# once (66µs+-66µs) by Log::Log4perl::Layout::PatternLayout::Multiline::BEGIN@4 at line 4 of Log/Log4perl/Layout/PatternLayout/Multiline.pm
# once (79µs+-79µs) by Moose::Meta::Method::BEGIN@14 at line 14 of Moose/Meta/Method.pm
# once (54µs+-54µs) by Class::MOP::Method::Inlined::BEGIN@15 at line 15 of Class/MOP/Method/Inlined.pm
# once (75µs+-75µs) by Class::MOP::Method::Generated::BEGIN@16 at line 16 of Class/MOP/Method/Generated.pm
# once (58µs+-58µs) by Moose::Meta::Mixin::AttributeCore::BEGIN@12 at line 12 of Moose/Meta/Mixin/AttributeCore.pm
# once (518µs+-518µs) by Class::MOP::Method::BEGIN@16 at line 16 of Class/MOP/Method.pm
# once (1.12ms+-1.12ms) by Class::MOP::Module::BEGIN@16 at line 16 of Class/MOP/Module.pm
# once (46µs+-46µs) by DBIx::Class::ResultSourceProxy::BEGIN@7 at line 7 of DBIx/Class/ResultSourceProxy.pm
# once (55µs+-55µs) by SQL::Translator::Schema::Object::BEGIN@38 at line 38 of SQL/Translator/Schema/Object.pm
# once (42µs+-42µs) by SQL::Translator::Schema::Object::BEGIN@39 at line 39 of SQL/Translator/Schema/Object.pm
# once (59µs+-59µs) by Log::Log4perl::Layout::PatternLayout::BEGIN@38 at line 38 of Log/Log4perl/Layout/PatternLayout.pm
# once (63µs+-63µs) by Log::Log4perl::Layout::SimpleLayout::BEGIN@14 at line 14 of Log/Log4perl/Layout/SimpleLayout.pm
# once (57µs+-57µs) by DBIx::Class::Row::BEGIN@6 at line 6 of DBIx/Class/Row.pm | ||||
59 | 1016 | 2.47ms | my $class = shift; | ||
60 | |||||
61 | return SUCCESS unless @_; | ||||
62 | |||||
63 | # List of base classes from which we will inherit %FIELDS. | ||||
64 | my $fields_base; | ||||
65 | |||||
66 | my $inheritor = caller(0); | ||||
67 | |||||
68 | my @bases; | ||||
69 | foreach my $base (@_) { | ||||
70 | 719 | 2.49ms | if ( $inheritor eq $base ) { | ||
71 | warn "Class '$inheritor' tried to inherit from itself\n"; | ||||
72 | } | ||||
73 | |||||
74 | 166 | 381µs | next if grep $_->isa($base), ($inheritor, @bases); # spent 381µs making 166 calls to UNIVERSAL::isa, avg 2µs/call | ||
75 | |||||
76 | # Following blocks help isolate $SIG{__DIE__} changes | ||||
77 | { | ||||
78 | 429 | 173µs | my $sigdie; | ||
79 | { | ||||
80 | 715 | 3.86ms | local $SIG{__DIE__}; | ||
81 | eval "require $base"; # spent 110µs executing statements in string eval
# spent 105µs executing statements in 8 string evals (merged)
# spent 105µs executing statements in 2 string evals (merged)
# spent 86µs executing statements in 5 string evals (merged)
# spent 83µs executing statements in string eval
# spent 81µs executing statements in 9 string evals (merged)
# spent 78µs executing statements in string eval
# spent 73µs executing statements in 8 string evals (merged)
# spent 72µs executing statements in string eval
# spent 72µs executing statements in string eval
# spent 72µs executing statements in 3 string evals (merged)
# spent 70µs executing statements in string eval
# spent 69µs executing statements in 2 string evals (merged)
# spent 68µs executing statements in 2 string evals (merged)
# spent 68µs executing statements in 2 string evals (merged)
# spent 66µs executing statements in string eval
# spent 66µs executing statements in string eval
# spent 64µs executing statements in 2 string evals (merged)
# spent 62µs executing statements in string eval
# spent 61µs executing statements in string eval
# spent 61µs executing statements in 3 string evals (merged)
# spent 61µs executing statements in 4 string evals (merged)
# spent 58µs executing statements in 3 string evals (merged)
# spent 58µs executing statements in string eval
# spent 57µs executing statements in string eval
# spent 56µs executing statements in string eval
# spent 56µs executing statements in string eval
# spent 55µs executing statements in string eval
# spent 54µs executing statements in 2 string evals (merged)
# spent 47µs executing statements in 21 string evals (merged)
# spent 24µs executing statements in 9 string evals (merged)
# spent 17µs executing statements in 7 string evals (merged)
# spent 10µs executing statements in 4 string evals (merged)
# spent 5µs executing statements in 2 string evals (merged)
# spent 4µs executing statements in 2 string evals (merged)
# spent 4µs executing statements in 2 string evals (merged)
# spent 4µs executing statements in 2 string evals (merged)
# spent 3µs executing statements in 2 string evals (merged)
# spent 3µs executing statements in 2 string evals (merged)
# spent 3µs executing statements in string eval
# spent 3µs executing statements in string eval
# spent 3µs executing statements in string eval
# spent 2µs executing statements in string eval
# spent 2µs executing statements in string eval
# spent 2µs executing statements in string eval
# spent 2µs executing statements in string eval
# spent 2µs executing statements in string eval
# spent 2µs executing statements in string eval
# spent 2µs executing statements in string eval
# spent 2µs executing statements in string eval
# spent 2µs executing statements in string eval
# spent 2µs executing statements in string eval
# spent 2µs executing statements in string eval
# spent 2µs executing statements in string eval
# spent 2µs executing statements in string eval
# spent 2µs executing statements in string eval
# spent 2µs executing statements in string eval
# spent 2µs executing statements in string eval
# spent 2µs executing statements in string eval | ||||
82 | # Only ignore "Can't locate" errors from our eval require. | ||||
83 | # Other fatal errors (syntax etc) must be reported. | ||||
84 | die if $@ && $@ !~ /^Can't locate .*? at \(eval /; | ||||
85 | unless (%{"$base\::"}) { | ||||
86 | require Carp; | ||||
87 | local $" = " "; | ||||
88 | Carp::croak(<<ERROR); | ||||
89 | Base class package "$base" is empty. | ||||
90 | (Perhaps you need to 'use' the module which defines that package first, | ||||
91 | or make that module available in \@INC (\@INC contains: @INC). | ||||
92 | ERROR | ||||
93 | } | ||||
94 | $sigdie = $SIG{__DIE__} || undef; | ||||
95 | } | ||||
96 | # Make sure a global $SIG{__DIE__} makes it out of the localization. | ||||
97 | $SIG{__DIE__} = $sigdie if defined $sigdie; | ||||
98 | } | ||||
99 | push @bases, $base; | ||||
100 | |||||
101 | 286 | 989µs | if ( has_fields($base) || has_attr($base) ) { # spent 587µs making 143 calls to base::has_fields, avg 4µs/call
# spent 402µs making 143 calls to base::has_attr, avg 3µs/call | ||
102 | # No multiple fields inheritance *suck* | ||||
103 | if ($fields_base) { | ||||
104 | require Carp; | ||||
105 | Carp::croak("Can't multiply inherit fields"); | ||||
106 | } else { | ||||
107 | $fields_base = $base; | ||||
108 | } | ||||
109 | } | ||||
110 | } | ||||
111 | # Save this until the end so it's all or nothing if the above loop croaks. | ||||
112 | push @{"$inheritor\::ISA"}, @bases; | ||||
113 | |||||
114 | if( defined $fields_base ) { | ||||
115 | inherit_fields($inheritor, $fields_base); | ||||
116 | } | ||||
117 | } | ||||
118 | |||||
119 | |||||
120 | sub inherit_fields { | ||||
121 | my($derived, $base) = @_; | ||||
122 | |||||
123 | return SUCCESS unless $base; | ||||
124 | |||||
125 | my $battr = get_attr($base); | ||||
126 | my $dattr = get_attr($derived); | ||||
127 | my $dfields = get_fields($derived); | ||||
128 | my $bfields = get_fields($base); | ||||
129 | |||||
130 | $dattr->[0] = @$battr; | ||||
131 | |||||
132 | if( keys %$dfields ) { | ||||
133 | warn <<"END"; | ||||
134 | $derived is inheriting from $base but already has its own fields! | ||||
135 | This will cause problems. Be sure you use base BEFORE declaring fields. | ||||
136 | END | ||||
137 | |||||
138 | } | ||||
139 | |||||
140 | # Iterate through the base's fields adding all the non-private | ||||
141 | # ones to the derived class. Hang on to the original attribute | ||||
142 | # (Public, Private, etc...) and add Inherited. | ||||
143 | # This is all too complicated to do efficiently with add_fields(). | ||||
144 | while (my($k,$v) = each %$bfields) { | ||||
145 | my $fno; | ||||
146 | if ($fno = $dfields->{$k} and $fno != $v) { | ||||
147 | require Carp; | ||||
148 | Carp::croak ("Inherited fields can't override existing fields"); | ||||
149 | } | ||||
150 | |||||
151 | if( $battr->[$v] & PRIVATE ) { | ||||
152 | $dattr->[$v] = PRIVATE | INHERITED; | ||||
153 | } | ||||
154 | else { | ||||
155 | $dattr->[$v] = INHERITED | $battr->[$v]; | ||||
156 | $dfields->{$k} = $v; | ||||
157 | } | ||||
158 | } | ||||
159 | |||||
160 | foreach my $idx (1..$#{$battr}) { | ||||
161 | next if defined $dattr->[$idx]; | ||||
162 | $dattr->[$idx] = $battr->[$idx] & INHERITED; | ||||
163 | } | ||||
164 | } | ||||
165 | |||||
166 | |||||
167 | 1 | 4µs | 1; | ||
168 | |||||
169 | __END__ |