File | /usr/local/lib/perl/5.10.0/Moose/Util/TypeConstraints/OptimizedConstraints.pm |
Statements Executed | 69019 |
Total Time | 0.083835800000024 seconds |
Calls | P | F | Exclusive Time |
Inclusive Time |
Subroutine |
---|---|---|---|---|---|
28000 | 4 | 2 | 116ms | 116ms | Str | Moose::Util::TypeConstraints::OptimizedConstraints::
13000 | 2 | 2 | 44.3ms | 44.3ms | ArrayRef | Moose::Util::TypeConstraints::OptimizedConstraints::
0 | 0 | 0 | 0s | 0s | BEGIN | Moose::Util::TypeConstraints::OptimizedConstraints::
0 | 0 | 0 | 0s | 0s | ClassName | Moose::Util::TypeConstraints::OptimizedConstraints::
0 | 0 | 0 | 0s | 0s | CodeRef | Moose::Util::TypeConstraints::OptimizedConstraints::
0 | 0 | 0 | 0s | 0s | FileHandle | Moose::Util::TypeConstraints::OptimizedConstraints::
0 | 0 | 0 | 0s | 0s | GlobRef | Moose::Util::TypeConstraints::OptimizedConstraints::
0 | 0 | 0 | 0s | 0s | HashRef | Moose::Util::TypeConstraints::OptimizedConstraints::
0 | 0 | 0 | 0s | 0s | Int | Moose::Util::TypeConstraints::OptimizedConstraints::
0 | 0 | 0 | 0s | 0s | Num | Moose::Util::TypeConstraints::OptimizedConstraints::
0 | 0 | 0 | 0s | 0s | Object | Moose::Util::TypeConstraints::OptimizedConstraints::
0 | 0 | 0 | 0s | 0s | Ref | Moose::Util::TypeConstraints::OptimizedConstraints::
0 | 0 | 0 | 0s | 0s | RegexpRef | Moose::Util::TypeConstraints::OptimizedConstraints::
0 | 0 | 0 | 0s | 0s | Role | Moose::Util::TypeConstraints::OptimizedConstraints::
0 | 0 | 0 | 0s | 0s | RoleName | Moose::Util::TypeConstraints::OptimizedConstraints::
0 | 0 | 0 | 0s | 0s | ScalarRef | Moose::Util::TypeConstraints::OptimizedConstraints::
0 | 0 | 0 | 0s | 0s | Value | Moose::Util::TypeConstraints::OptimizedConstraints::
Line | Stmts. | Exclusive Time | Avg. | Code |
---|---|---|---|---|
1 | package Moose::Util::TypeConstraints::OptimizedConstraints; | |||
2 | ||||
3 | 3 | 27µs | 9µs | use strict; # spent 8µs making 1 call to strict::import |
4 | 3 | 28µs | 9µs | use warnings; # spent 24µs making 1 call to warnings::import |
5 | ||||
6 | 3 | 28µs | 9µs | use Class::MOP; # spent 3µs making 1 call to import |
7 | 3 | 36µs | 12µs | use Moose::Deprecated; # spent 16µs making 1 call to Package::DeprecationManager::__ANON__[/usr/local/share/perl/5.10.0/Package/DeprecationManager.pm:61] |
8 | 3 | 640µs | 213µs | use Scalar::Util 'blessed', 'looks_like_number'; # spent 54µs making 1 call to Exporter::import |
9 | ||||
10 | 1 | 900ns | 900ns | our $VERSION = '1.15'; |
11 | 1 | 23µs | 23µs | $VERSION = eval $VERSION; |
12 | 1 | 700ns | 700ns | our $AUTHORITY = 'cpan:STEVAN'; |
13 | ||||
14 | sub Value { defined($_[0]) && !ref($_[0]) } | |||
15 | ||||
16 | sub Ref { ref($_[0]) } | |||
17 | ||||
18 | # We need to use a temporary here to flatten LVALUEs, for instance as in | |||
19 | # Str(substr($_,0,255)). | |||
20 | # spent 116ms within Moose::Util::TypeConstraints::OptimizedConstraints::Str which was called 28000 times, avg 4µs/call:
# 11000 times (46.7ms+0s) by Class::MOP::Method::Generated::__ANON__[generated method (unknown origin):21] or Class::MOP::Method::Generated::__ANON__[generated method (unknown origin):28] or Class::MOP::Method::Generated::__ANON__[generated method (unknown origin):25] or Class::MOP::Method::Generated::__ANON__[generated method (unknown origin):16] or Class::MOP::Method::Generated::__ANON__[generated method (unknown origin):63] or Class::MOP::Method::Generated::__ANON__[generated method (unknown origin):43] at line 15 of /home/tamil/util/marc-moose/generated method (unknown origin), avg 4µs/call
# 11000 times (42.5ms+0s) by Class::MOP::Method::Generated::__ANON__[generated method (unknown origin):63] at line 49 of /home/tamil/util/marc-moose/generated method (unknown origin), avg 4µs/call
# 5000 times (21.4ms+0s) by Class::MOP::Method::Generated::__ANON__[generated method (unknown origin):21] or Class::MOP::Method::Generated::__ANON__[generated method (unknown origin):28] or Class::MOP::Method::Generated::__ANON__[generated method (unknown origin):25] or Class::MOP::Method::Generated::__ANON__[generated method (unknown origin):63] or Class::MOP::Method::Generated::__ANON__[generated method (unknown origin):43] at line 21 of /home/tamil/util/marc-moose/generated method (unknown origin), avg 4µs/call
# 1000 times (4.91ms+0s) by Class::MOP::Method::Generated::__ANON__[accessor _leader of attribute leader defined at /home/tamil/util/marc-moose/lib/MARC/Moose/Record.pm:11] at line 10 of /home/tamil/util/marc-moose/accessor _leader of attribute leader defined at /home/tamil/util/marc-moose/lib/MARC/Moose/Record.pm, avg 5µs/call | |||
21 | 56000 | 63.7ms | 1µs | my $value = $_[0]; |
22 | defined($value) && ref(\$value) eq 'SCALAR' | |||
23 | } | |||
24 | ||||
25 | sub Num { !ref($_[0]) && looks_like_number($_[0]) } | |||
26 | ||||
27 | # using a temporary here because regex matching promotes an IV to a PV, | |||
28 | # and that confuses some things (like JSON.pm) | |||
29 | sub Int { | |||
30 | my $value = $_[0]; | |||
31 | defined($value) && !ref($value) && $value =~ /^-?[0-9]+$/ | |||
32 | } | |||
33 | ||||
34 | sub ScalarRef { ref($_[0]) eq 'SCALAR' || ref($_[0]) eq 'REF' } | |||
35 | 13000 | 19.3ms | 1µs | # spent 44.3ms within Moose::Util::TypeConstraints::OptimizedConstraints::ArrayRef which was called 13000 times, avg 3µs/call:
# 12000 times (41.1ms+0s) by Class::MOP::Method::Generated::__ANON__[generated method (unknown origin):63] or Class::MOP::Method::Generated::__ANON__[generated method (unknown origin):43] at line 35 of /home/tamil/util/marc-moose/generated method (unknown origin), avg 3µs/call
# 1000 times (3.24ms+0s) by Class::MOP::Method::Generated::__ANON__[accessor fields defined at /home/tamil/util/marc-moose/lib/MARC/Moose/Record.pm:35] at line 27 of /home/tamil/util/marc-moose/accessor fields defined at /home/tamil/util/marc-moose/lib/MARC/Moose/Record.pm, avg 3µs/call |
36 | sub HashRef { ref($_[0]) eq 'HASH' } | |||
37 | sub CodeRef { ref($_[0]) eq 'CODE' } | |||
38 | sub RegexpRef { ref($_[0]) eq 'Regexp' } | |||
39 | sub GlobRef { ref($_[0]) eq 'GLOB' } | |||
40 | ||||
41 | sub FileHandle { ref($_[0]) eq 'GLOB' && Scalar::Util::openhandle($_[0]) or blessed($_[0]) && $_[0]->isa("IO::Handle") } | |||
42 | ||||
43 | sub Object { blessed($_[0]) && blessed($_[0]) ne 'Regexp' } | |||
44 | ||||
45 | sub Role { | |||
46 | Moose::Deprecated::deprecated( | |||
47 | feature => 'Role type', | |||
48 | message => | |||
49 | 'The Role type has been deprecated. Maybe you meant to create a RoleName type?' | |||
50 | ); | |||
51 | blessed( $_[0] ) && $_[0]->can('does'); | |||
52 | } | |||
53 | ||||
54 | sub ClassName { | |||
55 | return Class::MOP::is_class_loaded( $_[0] ); | |||
56 | } | |||
57 | ||||
58 | sub RoleName { | |||
59 | ClassName($_[0]) | |||
60 | && (Class::MOP::class_of($_[0]) || return)->isa('Moose::Meta::Role') | |||
61 | } | |||
62 | ||||
63 | # NOTE: | |||
64 | # we have XS versions too, ... | |||
65 | # 04:09 <@konobi> nothingmuch: konobi.co.uk/code/utilsxs.tar.gz | |||
66 | # 04:09 <@konobi> or utilxs.tar.gz iirc | |||
67 | ||||
68 | 1 | 4µs | 4µs | 1; |
69 | ||||
70 | __END__ | |||
71 | ||||
72 | =pod | |||
73 | ||||
74 | =head1 NAME | |||
75 | ||||
76 | Moose::Util::TypeConstraints::OptimizedConstraints - Optimized constraint | |||
77 | bodies for various moose types | |||
78 | ||||
79 | =head1 DESCRIPTION | |||
80 | ||||
81 | This file contains the hand optimized versions of Moose type constraints, | |||
82 | no user serviceable parts inside. | |||
83 | ||||
84 | =head1 FUNCTIONS | |||
85 | ||||
86 | =over 4 | |||
87 | ||||
88 | =item C<Value> | |||
89 | ||||
90 | =item C<Ref> | |||
91 | ||||
92 | =item C<Str> | |||
93 | ||||
94 | =item C<Num> | |||
95 | ||||
96 | =item C<Int> | |||
97 | ||||
98 | =item C<ScalarRef> | |||
99 | ||||
100 | =item C<ArrayRef> | |||
101 | ||||
102 | =item C<HashRef> | |||
103 | ||||
104 | =item C<CodeRef> | |||
105 | ||||
106 | =item C<RegexpRef> | |||
107 | ||||
108 | =item C<GlobRef> | |||
109 | ||||
110 | =item C<FileHandle> | |||
111 | ||||
112 | =item C<Object> | |||
113 | ||||
114 | =item C<Role> | |||
115 | ||||
116 | =item C<ClassName> | |||
117 | ||||
118 | =item C<RoleName> | |||
119 | ||||
120 | =back | |||
121 | ||||
122 | =head1 BUGS | |||
123 | ||||
124 | See L<Moose/BUGS> for details on reporting bugs. | |||
125 | ||||
126 | =head1 AUTHOR | |||
127 | ||||
128 | Yuval Kogman E<lt>nothingmuch@cpan.orgE<gt> | |||
129 | ||||
130 | =head1 COPYRIGHT AND LICENSE | |||
131 | ||||
132 | Copyright 2007-2009 by Infinity Interactive, Inc. | |||
133 | ||||
134 | L<http://www.iinteractive.com> | |||
135 | ||||
136 | This library is free software; you can redistribute it and/or modify | |||
137 | it under the same terms as Perl itself. | |||
138 | ||||
139 | =cut |