← Index
Performance Profile   « block view • line view • sub view »
For t/test-parsing
  Run on Sun Nov 14 09:49:57 2010
Reported on Sun Nov 14 09:50:11 2010

File /usr/local/lib/perl/5.10.0/metaclass.pm
Statements Executed 243
Total Time 0.0011395 seconds
Subroutines — ordered by exclusive time
Calls P F Exclusive
Time
Inclusive
Time
Subroutine
191919544µs16.2msmetaclass::::importmetaclass::import
0000s0smetaclass::::BEGINmetaclass::BEGIN
LineStmts.Exclusive
Time
Avg.Code
1
2package metaclass;
3
4323µs8µsuse strict;
# spent 7µs making 1 call to strict::import
5334µs11µsuse warnings;
# spent 21µs making 1 call to warnings::import
6
7333µs11µsuse Carp 'confess';
# spent 51µs making 1 call to Exporter::import
8330µs10µsuse Scalar::Util 'blessed';
# spent 35µs making 1 call to Exporter::import
9359µs20µsuse Try::Tiny;
# spent 48µs making 1 call to Exporter::import
10
111800ns800nsour $VERSION = '1.09';
12122µs22µs$VERSION = eval $VERSION;
131600ns600nsour $AUTHORITY = 'cpan:STEVAN';
14
153242µs81µsuse Class::MOP;
# spent 3µs making 1 call to import
16
17
# spent 16.2ms (544µs+15.7) within metaclass::import which was called 19 times, avg 855µs/call: # once (23µs+989µs) at line 6 of /usr/local/lib/perl/5.10.0/Moose/Meta/TypeConstraint.pm # once (29µs+967µs) at line 5 of /usr/local/lib/perl/5.10.0/Moose/Meta/Role/Composite.pm # once (29µs+917µs) at line 6 of /usr/local/lib/perl/5.10.0/Moose/Meta/TypeCoercion.pm # once (26µs+833µs) at line 5 of /usr/local/lib/perl/5.10.0/Moose/Meta/TypeConstraint/Parameterized.pm # once (30µs+826µs) at line 5 of /usr/local/lib/perl/5.10.0/Moose/Meta/TypeConstraint/DuckType.pm # once (29µs+823µs) at line 6 of /usr/local/lib/perl/5.10.0/Moose/Meta/TypeCoercion/Union.pm # once (24µs+826µs) by Moose::Meta::Role::Application::BEGIN at line 5 of /usr/local/lib/perl/5.10.0/Moose/Meta/Role/Application.pm # once (39µs+804µs) at line 5 of /usr/local/lib/perl/5.10.0/Moose/Meta/Role/Application/ToInstance.pm # once (31µs+812µs) at line 6 of /usr/local/lib/perl/5.10.0/Moose/Meta/Role.pm # once (32µs+803µs) at line 5 of /usr/local/lib/perl/5.10.0/Moose/Meta/TypeConstraint/Enum.pm # once (31µs+799µs) at line 5 of /usr/local/lib/perl/5.10.0/Moose/Meta/Role/Application/RoleSummation.pm # once (32µs+795µs) at line 5 of /usr/local/lib/perl/5.10.0/Moose/Meta/Role/Application/ToClass.pm # once (30µs+795µs) at line 5 of /usr/local/lib/perl/5.10.0/Moose/Meta/TypeConstraint/Role.pm # once (31µs+788µs) at line 6 of /usr/local/lib/perl/5.10.0/Moose/Meta/TypeConstraint/Registry.pm # once (25µs+791µs) at line 5 of /usr/local/lib/perl/5.10.0/Moose/Meta/TypeConstraint/Class.pm # once (23µs+790µs) at line 6 of /usr/local/lib/perl/5.10.0/Moose/Meta/Role/Method/Required.pm # once (25µs+787µs) at line 5 of /usr/local/lib/perl/5.10.0/Moose/Meta/Role/Application/ToRole.pm # once (29µs+783µs) at line 5 of /usr/local/lib/perl/5.10.0/Moose/Meta/TypeConstraint/Parameterizable.pm # once (27µs+763µs) at line 6 of /usr/local/lib/perl/5.10.0/Moose/Meta/TypeConstraint/Union.pm
sub import {
182043µs2µs my ( $class, @args ) = @_;
19
202036µs2µs unshift @args, "metaclass" if @args % 2 == 1;
212030µs2µs my %options = @args;
22
232024µs1µs my $meta_name = exists $options{meta_name} ? $options{meta_name} : 'meta';
242023µs1µs my $metaclass = delete $options{metaclass};
25
262021µs1µs unless ( defined $metaclass ) {
27 $metaclass = "Class::MOP::Class";
28 } else {
2916µs6µs Class::MOP::load_class($metaclass);
# spent 72µs making 1 call to Class::MOP::load_class
30 }
31
3220148µs7µs ($metaclass->isa('Class::MOP::Class'))
# spent 95µs making 20 calls to UNIVERSAL::isa, avg 5µs/call
33 || confess "The metaclass ($metaclass) must be derived from Class::MOP::Class";
34
35 # make sure the custom metaclasses get loaded
362068µs3µs foreach my $key (grep { /_(?:meta)?class$/ } keys %options) {
37 unless ( ref( my $class = $options{$key} ) ) {
38 Class::MOP::load_class($class)
39 }
40 }
41
422020µs975ns my $package = caller();
43
44 # create a meta object so we can install &meta
4520108µs5µs my $meta = $metaclass->initialize($package => %options);
# spent 3.48ms making 19 calls to Class::MOP::Class::initialize, avg 183µs/call # spent 1.85ms making 1 call to Moose::Meta::Class::initialize
4620164µs8µs $meta->_add_meta_method($meta_name)
# spent 14.3ms making 20 calls to Class::MOP::Mixin::HasMethods::_add_meta_method, avg 715µs/call
47 if defined $meta_name;
48}
49
5014µs4µs1;
51
52__END__
53
54=pod
55
56=head1 NAME
57
58metaclass - a pragma for installing and using Class::MOP metaclasses
59
60=head1 SYNOPSIS
61
62 package MyClass;
63
64 # use Class::MOP::Class
65 use metaclass;
66
67 # ... or use a custom metaclass
68 use metaclass 'MyMetaClass';
69
70 # ... or use a custom metaclass
71 # and custom attribute and method
72 # metaclasses
73 use metaclass 'MyMetaClass' => (
74 'attribute_metaclass' => 'MyAttributeMetaClass',
75 'method_metaclass' => 'MyMethodMetaClass',
76 );
77
78 # ... or just specify custom attribute
79 # and method classes, and Class::MOP::Class
80 # is the assumed metaclass
81 use metaclass (
82 'attribute_metaclass' => 'MyAttributeMetaClass',
83 'method_metaclass' => 'MyMethodMetaClass',
84 );
85
86 # if we'd rather not install a 'meta' method, we can do this
87 use metaclass meta_name => undef;
88 # or if we'd like it to have a different name,
89 use metaclass meta_name => 'my_meta';
90
91=head1 DESCRIPTION
92
93This is a pragma to make it easier to use a specific metaclass
94and a set of custom attribute and method metaclasses. It also
95installs a C<meta> method to your class as well, unless C<undef>
96is passed to the C<meta_name> option.
97
98=head1 AUTHORS
99
100Stevan Little E<lt>stevan@iinteractive.comE<gt>
101
102=head1 COPYRIGHT AND LICENSE
103
104Copyright 2006-2010 by Infinity Interactive, Inc.
105
106L<http://www.iinteractive.com>
107
108This library is free software; you can redistribute it and/or modify
109it under the same terms as Perl itself.
110
111=cut