Profile of /usr/local/lib/perl5/site_perl/5.10.1/darwin-2level/metaclass.pm

← Index
NYTProf Performance Profile «block view•line view•sub view»
For 05.Domain_and_Item.t
Run on Tue May 4 17:21:41 2010
Reported on Tue May 4 17:23:08 2010

File | /usr/local/lib/perl5/site_perl/5.10.1/darwin-2level/metaclass.pm
Statements Executed | 263
Statement Execution Time | 1.05ms

Subroutines — ordered by exclusive time
Calls | P | F | Exclusive Time | Inclusive Time | Subroutine
--- | --- | --- | --- | --- | ---
20 | 20 | 20 | 369µs | 3.02ms | metaclass::::importmetaclass::import
1 | 1 | 1 | 13µs | 15µs | metaclass::::BEGIN@4metaclass::BEGIN@4
1 | 1 | 1 | 11µs | 33µs | metaclass::::BEGIN@8metaclass::BEGIN@8
1 | 1 | 1 | 6µs | 15µs | metaclass::::BEGIN@5metaclass::BEGIN@5
1 | 1 | 1 | 6µs | 43µs | metaclass::::BEGIN@7metaclass::BEGIN@7
1 | 1 | 1 | 4µs | 4µs | metaclass::::BEGIN@14metaclass::BEGIN@14
0 | 0 | 0 | 0s | 0s | metaclass::::__ANON__[:51]metaclass::__ANON__[:51]

Call graph for these subroutines as a Graphviz dot language file.

Line | State ments | Time on line | Calls | Time in subs | Code
--- | --- | --- | --- | --- | ---
1 |  |  |  |  |
2 |  |  |  |  | package metaclass;
3 |  |  |  |  |
4 | 3 | 19µs | 2 | 18µs | # spent 15µs (13+3) within metaclass::BEGIN@4 which was called # once (13µs+3µs) by Moose::Meta::TypeConstraint::BEGIN@6 at line 4 use strict; # spent 15µs making 1 call to metaclass::BEGIN@4 # spent 2µs making 1 call to strict::import
5 | 3 | 20µs | 2 | 23µs | # spent 15µs (6+8) within metaclass::BEGIN@5 which was called # once (6µs+8µs) by Moose::Meta::TypeConstraint::BEGIN@6 at line 5 use warnings; # spent 15µs making 1 call to metaclass::BEGIN@5 # spent 8µs making 1 call to warnings::import
6 |  |  |  |  |
7 | 3 | 25µs | 2 | 80µs | # spent 43µs (6+37) within metaclass::BEGIN@7 which was called # once (6µs+37µs) by Moose::Meta::TypeConstraint::BEGIN@6 at line 7 use Carp 'confess'; # spent 43µs making 1 call to metaclass::BEGIN@7 # spent 37µs making 1 call to Exporter::import
8 | 3 | 46µs | 2 | 55µs | # spent 33µs (11+22) within metaclass::BEGIN@8 which was called # once (11µs+22µs) by Moose::Meta::TypeConstraint::BEGIN@6 at line 8 use Scalar::Util 'blessed'; # spent 33µs making 1 call to metaclass::BEGIN@8 # spent 22µs making 1 call to Exporter::import
9 |  |  |  |  |
10 | 1 | 700ns |  |  | our $VERSION = '0.98';
11 | 1 | 13µs |  |  | $VERSION = eval $VERSION;
12 | 1 | 300ns |  |  | our $AUTHORITY = 'cpan:STEVAN';
13 |  |  |  |  |
14 | 3 | 185µs | 1 | 4µs | # spent 4µs within metaclass::BEGIN@14 which was called # once (4µs+0s) by Moose::Meta::TypeConstraint::BEGIN@6 at line 14 use Class::MOP; # spent 4µs making 1 call to metaclass::BEGIN@14
15 |  |  |  |  |
16 |  |  |  |  | # spent 3.02ms (369µs+2.65) within metaclass::import which was called 20 times, avg 151µs/call: # once (40µs+1.06ms) by Moose::Object::BEGIN@13 at line 15 of if.pm # once (23µs+99µs) by Moose::Meta::Role::Composite::BEGIN@5 at line 5 of Moose/Meta/Role/Composite.pm # once (20µs+100µs) by Moose::Meta::TypeConstraint::Union::BEGIN@6 at line 6 of Moose/Meta/TypeConstraint/Union.pm # once (16µs+94µs) by Moose::Meta::TypeCoercion::BEGIN@6 at line 6 of Moose/Meta/TypeCoercion.pm # once (17µs+93µs) by Moose::Meta::TypeConstraint::Registry::BEGIN@6 at line 6 of Moose/Meta/TypeConstraint/Registry.pm # once (17µs+88µs) by Moose::Meta::Role::Application::ToClass::BEGIN@5 at line 5 of Moose/Meta/Role/Application/ToClass.pm # once (22µs+83µs) by Moose::Meta::TypeConstraint::DuckType::BEGIN@5 at line 5 of Moose/Meta/TypeConstraint/DuckType.pm # once (17µs+86µs) by Moose::Meta::Role::BEGIN@6 at line 6 of Moose/Meta/Role.pm # once (16µs+85µs) by Moose::Meta::Role::Application::BEGIN@5 at line 5 of Moose/Meta/Role/Application.pm # once (21µs+78µs) by Moose::Meta::TypeConstraint::BEGIN@6 at line 6 of Moose/Meta/TypeConstraint.pm # once (16µs+82µs) by Moose::Meta::TypeConstraint::Role::BEGIN@5 at line 5 of Moose/Meta/TypeConstraint/Role.pm # once (16µs+81µs) by Moose::Meta::TypeConstraint::Enum::BEGIN@5 at line 5 of Moose/Meta/TypeConstraint/Enum.pm # once (17µs+79µs) by Moose::Meta::Role::Application::ToRole::BEGIN@5 at line 5 of Moose/Meta/Role/Application/ToRole.pm # once (15µs+81µs) by Moose::Meta::TypeCoercion::Union::BEGIN@6 at line 6 of Moose/Meta/TypeCoercion/Union.pm # once (16µs+78µs) by Moose::Meta::Role::Method::Required::BEGIN@6 at line 6 of Moose/Meta/Role/Method/Required.pm # once (16µs+78µs) by Moose::Meta::Role::Application::RoleSummation::BEGIN@5 at line 5 of Moose/Meta/Role/Application/RoleSummation.pm # once (16µs+78µs) by Moose::Meta::Role::Application::ToInstance::BEGIN@5 at line 5 of Moose/Meta/Role/Application/ToInstance.pm # once (16µs+77µs) by Moose::Meta::TypeConstraint::Parameterized::BEGIN@5 at line 5 of Moose/Meta/TypeConstraint/Parameterized.pm # once (16µs+76µs) by Moose::Meta::TypeConstraint::Class::BEGIN@5 at line 5 of Moose/Meta/TypeConstraint/Class.pm # once (16µs+76µs) by Moose::Meta::TypeConstraint::Parameterizable::BEGIN@5 at line 5 of Moose/Meta/TypeConstraint/Parameterizable.pm sub import {
17 | 20 | 18µs |  |  | my ( $class, @args ) = @_;
18 |  |  |  |  |
19 | 20 | 16µs |  |  | unshift @args, "metaclass" if @args % 2 == 1;
20 | 20 | 12µs |  |  | my %options = @args;
21 |  |  |  |  |
22 | 20 | 10µs |  |  | my $metaclass = delete $options{metaclass};
23 |  |  |  |  |
24 | 20 | 12µs |  |  | unless ( defined $metaclass ) {
25 |  |  |  |  | $metaclass = "Class::MOP::Class";
26 |  |  |  |  | } else {
27 | 1 | 2µs | 1 | 49µs | Class::MOP::load_class($metaclass); # spent 49µs making 1 call to Class::MOP::load_class
28 |  |  |  |  | }
29 |  |  |  |  |
30 | 20 | 100µs | 20 | 30µs | ($metaclass->isa('Class::MOP::Class')) # spent 30µs making 20 calls to UNIVERSAL::isa, avg 2µs/call
31 |  |  |  |  | || confess "The metaclass ($metaclass) must be derived from Class::MOP::Class";
32 |  |  |  |  |
33 |  |  |  |  | # make sure the custom metaclasses get loaded
34 | 20 | 37µs |  |  | foreach my $key (grep { /_(?:meta)?class$/ } keys %options) {
35 |  |  |  |  | unless ( ref( my $class = $options{$key} ) ) {
36 |  |  |  |  | Class::MOP::load_class($class)
37 |  |  |  |  | }
38 |  |  |  |  | }
39 |  |  |  |  |
40 | 20 | 10µs |  |  | my $package = caller();
41 |  |  |  |  |
42 |  |  |  |  | # create a meta object so we can install &meta
43 | 20 | 34µs | 20 | 1.88ms | my $meta = $metaclass->initialize($package => %options); # spent 972µs making 1 call to Moose::Meta::Class::initialize # spent 911µs making 19 calls to Class::MOP::Class::initialize, avg 48µs/call
44 |  |  |  |  | $meta->add_method('meta' => sub {
45 |  |  |  |  | # we must re-initialize so that it
46 |  |  |  |  | # works as expected in subclasses,
47 |  |  |  |  | # since metaclass instances are
48 |  |  |  |  | # singletons, this is not really a
49 |  |  |  |  | # big deal anyway.
50 | 43 | 337µs | 86 | 326µs | $metaclass->initialize((blessed($_[0]) || $_[0]) => %options) # spent 302µs making 43 calls to Class::MOP::Class::initialize, avg 7µs/call # spent 25µs making 43 calls to Scalar::Util::blessed, avg 574ns/call
51 | 20 | 143µs | 20 | 690µs | }); # spent 690µs making 20 calls to Class::MOP::Mixin::HasMethods::add_method, avg 34µs/call
52 |  |  |  |  | }
53 |  |  |  |  |
54 | 1 | 10µs |  |  | 1;
55 |  |  |  |  |
56 |  |  |  |  | __END__
57 |  |  |  |  |
58 |  |  |  |  | =pod
59 |  |  |  |  |
60 |  |  |  |  | =head1 NAME
61 |  |  |  |  |
62 |  |  |  |  | metaclass - a pragma for installing and using Class::MOP metaclasses
63 |  |  |  |  |
64 |  |  |  |  | =head1 SYNOPSIS
65 |  |  |  |  |
66 |  |  |  |  | package MyClass;
67 |  |  |  |  |
68 |  |  |  |  | # use Class::MOP::Class
69 |  |  |  |  | use metaclass;
70 |  |  |  |  |
71 |  |  |  |  | # ... or use a custom metaclass
72 |  |  |  |  | use metaclass 'MyMetaClass';
73 |  |  |  |  |
74 |  |  |  |  | # ... or use a custom metaclass
75 |  |  |  |  | # and custom attribute and method
76 |  |  |  |  | # metaclasses
77 |  |  |  |  | use metaclass 'MyMetaClass' => (
78 |  |  |  |  | 'attribute_metaclass' => 'MyAttributeMetaClass',
79 |  |  |  |  | 'method_metaclass' => 'MyMethodMetaClass',
80 |  |  |  |  | );
81 |  |  |  |  |
82 |  |  |  |  | # ... or just specify custom attribute
83 |  |  |  |  | # and method classes, and Class::MOP::Class
84 |  |  |  |  | # is the assumed metaclass
85 |  |  |  |  | use metaclass (
86 |  |  |  |  | 'attribute_metaclass' => 'MyAttributeMetaClass',
87 |  |  |  |  | 'method_metaclass' => 'MyMethodMetaClass',
88 |  |  |  |  | );
89 |  |  |  |  |
90 |  |  |  |  | =head1 DESCRIPTION
91 |  |  |  |  |
92 |  |  |  |  | This is a pragma to make it easier to use a specific metaclass
93 |  |  |  |  | and a set of custom attribute and method metaclasses. It also
94 |  |  |  |  | installs a C<meta> method to your class as well.
95 |  |  |  |  |
96 |  |  |  |  | =head1 AUTHORS
97 |  |  |  |  |
98 |  |  |  |  | Stevan Little E<lt>stevan@iinteractive.comE<gt>
99 |  |  |  |  |
100 |  |  |  |  | =head1 COPYRIGHT AND LICENSE
101 |  |  |  |  |
102 |  |  |  |  | Copyright 2006-2010 by Infinity Interactive, Inc.
103 |  |  |  |  |
104 |  |  |  |  | L<http://www.iinteractive.com>
105 |  |  |  |  |
106 |  |  |  |  | This library is free software; you can redistribute it and/or modify
107 |  |  |  |  | it under the same terms as Perl itself.
108 |  |  |  |  |
109 |  |  |  |  | =cut