← 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:22:21 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
202020369µs3.02msmetaclass::::importmetaclass::import
11113µs15µsmetaclass::::BEGIN@4metaclass::BEGIN@4
11111µs33µsmetaclass::::BEGIN@8metaclass::BEGIN@8
1116µs15µsmetaclass::::BEGIN@5metaclass::BEGIN@5
1116µs43µsmetaclass::::BEGIN@7metaclass::BEGIN@7
1114µs4µsmetaclass::::BEGIN@14metaclass::BEGIN@14
0000s0smetaclass::::__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
2package metaclass;
3
4319µs218µ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
5320µs223µ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
7325µs280µ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
8346µs255µ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
101700nsour $VERSION = '0.98';
11113µs$VERSION = eval $VERSION;
121300nsour $AUTHORITY = 'cpan:STEVAN';
13
143185µs14µ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 {
17201393µs my ( $class, @args ) = @_;
18
19 unshift @args, "metaclass" if @args % 2 == 1;
20 my %options = @args;
21
22 my $metaclass = delete $options{metaclass};
23
24 unless ( defined $metaclass ) {
25 $metaclass = "Class::MOP::Class";
26 } else {
27 Class::MOP::load_class($metaclass);
# spent 49µs making 1 call to Class::MOP::load_class
28 }
29
30 ($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 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 my $package = caller();
41
42 # create a meta object so we can install &meta
43 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.
5043337µs86326µ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 });
# spent 690µs making 20 calls to Class::MOP::Mixin::HasMethods::add_method, avg 34µs/call
52}
53
54110µs1;
55
56__END__
57
58=pod
59
60=head1 NAME
61
62metaclass - 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
92This is a pragma to make it easier to use a specific metaclass
93and a set of custom attribute and method metaclasses. It also
94installs a C<meta> method to your class as well.
95
96=head1 AUTHORS
97
98Stevan Little E<lt>stevan@iinteractive.comE<gt>
99
100=head1 COPYRIGHT AND LICENSE
101
102Copyright 2006-2010 by Infinity Interactive, Inc.
103
104L<http://www.iinteractive.com>
105
106This library is free software; you can redistribute it and/or modify
107it under the same terms as Perl itself.
108
109=cut