← Index
NYTProf Performance Profile   « block view • line view • sub view »
For mentat.storage.mongo.pl
  Run on Tue Jun 24 10:04:38 2014
Reported on Tue Jun 24 10:05:31 2014

Filename/usr/local/lib/perl/5.14.2/Moose/Meta/TypeCoercion.pm
StatementsExecuted 45 statements in 758µs
Subroutines
Calls P F Exclusive
Time
Inclusive
Time
Subroutine
1115.56ms83.1msMoose::Meta::TypeCoercion::::BEGIN@14Moose::Meta::TypeCoercion::BEGIN@14
21147µs122µsMoose::Meta::TypeCoercion::::compile_type_coercionMoose::Meta::TypeCoercion::compile_type_coercion
21120µs548µsMoose::Meta::TypeCoercion::::newMoose::Meta::TypeCoercion::new
1119µs9µsMoose::Meta::TypeCoercion::::BEGIN@3Moose::Meta::TypeCoercion::BEGIN@3
1118µs11µsMoose::Meta::TypeCoercion::::BEGIN@10Moose::Meta::TypeCoercion::BEGIN@10
1117µs12µsMoose::Meta::TypeCoercion::::BEGIN@11Moose::Meta::TypeCoercion::BEGIN@11
1116µs487µsMoose::Meta::TypeCoercion::::BEGIN@12Moose::Meta::TypeCoercion::BEGIN@12
1115µs5µsMoose::Meta::TypeCoercion::::BEGIN@15Moose::Meta::TypeCoercion::BEGIN@15
0000s0sMoose::Meta::TypeCoercion::::__ANON__[:19]Moose::Meta::TypeCoercion::__ANON__[:19]
0000s0sMoose::Meta::TypeCoercion::::__ANON__[:72]Moose::Meta::TypeCoercion::__ANON__[:72]
0000s0sMoose::Meta::TypeCoercion::::add_type_coercionsMoose::Meta::TypeCoercion::add_type_coercions
0000s0sMoose::Meta::TypeCoercion::::coerceMoose::Meta::TypeCoercion::coerce
0000s0sMoose::Meta::TypeCoercion::::has_coercion_for_typeMoose::Meta::TypeCoercion::has_coercion_for_type
Call graph for these subroutines as a Graphviz dot language file.
Line State
ments
Time
on line
Calls Time
in subs
Code
1
2package Moose::Meta::TypeCoercion;
3
# spent 9µs within Moose::Meta::TypeCoercion::BEGIN@3 which was called: # once (9µs+0s) by Moose::BEGIN@29 at line 5
BEGIN {
415µs $Moose::Meta::TypeCoercion::AUTHORITY = 'cpan:STEVAN';
5131µs19µs}
# spent 9µs making 1 call to Moose::Meta::TypeCoercion::BEGIN@3
6{
72900ns $Moose::Meta::TypeCoercion::VERSION = '2.1005';
8}
9
10222µs214µs
# spent 11µs (8+3) within Moose::Meta::TypeCoercion::BEGIN@10 which was called: # once (8µs+3µs) by Moose::BEGIN@29 at line 10
use strict;
# spent 11µs making 1 call to Moose::Meta::TypeCoercion::BEGIN@10 # spent 3µs making 1 call to strict::import
11221µs217µs
# spent 12µs (7+5) within Moose::Meta::TypeCoercion::BEGIN@11 which was called: # once (7µs+5µs) by Moose::BEGIN@29 at line 11
use warnings;
# spent 12µs making 1 call to Moose::Meta::TypeCoercion::BEGIN@11 # spent 5µs making 1 call to warnings::import
12231µs2968µs
# spent 487µs (6+481) within Moose::Meta::TypeCoercion::BEGIN@12 which was called: # once (6µs+481µs) by Moose::BEGIN@29 at line 12
use metaclass;
# spent 487µs making 1 call to Moose::Meta::TypeCoercion::BEGIN@12 # spent 481µs making 1 call to metaclass::import
13
142130µs183.1ms
# spent 83.1ms (5.56+77.6) within Moose::Meta::TypeCoercion::BEGIN@14 which was called: # once (5.56ms+77.6ms) by Moose::BEGIN@29 at line 14
use Moose::Meta::Attribute;
# spent 83.1ms making 1 call to Moose::Meta::TypeCoercion::BEGIN@14
152436µs15µs
# spent 5µs within Moose::Meta::TypeCoercion::BEGIN@15 which was called: # once (5µs+0s) by Moose::BEGIN@29 at line 15
use Moose::Util::TypeConstraints ();
# spent 5µs making 1 call to Moose::Meta::TypeCoercion::BEGIN@15
16
17__PACKAGE__->meta->add_attribute('type_coercion_map' => (
18 reader => 'type_coercion_map',
19 default => sub { [] },
2017µs3377µs Class::MOP::_definition_context(),
# spent 350µs making 1 call to Class::MOP::Mixin::HasAttributes::add_attribute # spent 21µs making 1 call to Moose::Meta::TypeCoercion::meta # spent 6µs making 1 call to Class::MOP::_definition_context
21));
22
2316µs43.17ms__PACKAGE__->meta->add_attribute(
# spent 2.28ms making 1 call to Class::MOP::Mixin::HasAttributes::add_attribute # spent 870µs making 1 call to Moose::Meta::Attribute::new # spent 12µs making 1 call to Moose::Meta::TypeCoercion::meta # spent 5µs making 1 call to Class::MOP::_definition_context
24 Moose::Meta::Attribute->new('type_constraint' => (
25 reader => 'type_constraint',
26 weak_ref => 1,
27 Class::MOP::_definition_context(),
28 ))
29);
30
31# private accessor
3214µs3321µs__PACKAGE__->meta->add_attribute('compiled_type_coercion' => (
# spent 305µs making 1 call to Class::MOP::Mixin::HasAttributes::add_attribute # spent 11µs making 1 call to Moose::Meta::TypeCoercion::meta # spent 6µs making 1 call to Class::MOP::_definition_context
33 accessor => '_compiled_type_coercion',
34 Class::MOP::_definition_context(),
35));
36
37
# spent 548µs (20+528) within Moose::Meta::TypeCoercion::new which was called 2 times, avg 274µs/call: # 2 times (20µs+528µs) by Moose::Util::TypeConstraints::_install_type_coercions at line 594 of Moose/Util/TypeConstraints.pm, avg 274µs/call
sub new {
382900ns my $class = shift;
3926µs4407µs my $self = Class::MOP::class_of($class)->new_object(@_);
# spent 399µs making 2 calls to Class::MOP::Class::new_object, avg 199µs/call # spent 8µs making 2 calls to Class::MOP::class_of, avg 4µs/call
4024µs2122µs $self->compile_type_coercion;
# spent 122µs making 2 calls to Moose::Meta::TypeCoercion::compile_type_coercion, avg 61µs/call
4125µs return $self;
42}
43
44
# spent 122µs (47+74) within Moose::Meta::TypeCoercion::compile_type_coercion which was called 2 times, avg 61µs/call: # 2 times (47µs+74µs) by Moose::Meta::TypeCoercion::new at line 40, avg 61µs/call
sub compile_type_coercion {
452900ns my $self = shift;
4647µs27µs my @coercion_map = @{$self->type_coercion_map};
# spent 7µs making 2 calls to Moose::Meta::TypeCoercion::type_coercion_map, avg 4µs/call
472500ns my @coercions;
4821µs while (@coercion_map) {
4922µs my ($constraint_name, $action) = splice(@coercion_map, 0, 2);
5024µs256µs my $type_constraint = ref $constraint_name ? $constraint_name : Moose::Util::TypeConstraints::find_or_parse_type_constraint($constraint_name);
# spent 56µs making 2 calls to Moose::Util::TypeConstraints::find_or_parse_type_constraint, avg 28µs/call
51
522900ns unless ( defined $type_constraint ) {
53 require Moose;
54 Moose->throw_error("Could not find the type constraint ($constraint_name) to coerce from");
55 }
56
5726µs23µs push @coercions => [
# spent 3µs making 2 calls to Moose::Meta::TypeConstraint::_compiled_type_constraint, avg 2µs/call
58 $type_constraint->_compiled_type_constraint,
59 $action
60 ];
61 }
62 $self->_compiled_type_coercion(sub {
63 my $thing = shift;
64 foreach my $coercion (@coercions) {
65 my ($constraint, $converter) = @$coercion;
66 if ($constraint->($thing)) {
67 local $_ = $thing;
68 return $converter->($thing);
69 }
70 }
71 return $thing;
72216µs27µs });
# spent 7µs making 2 calls to Moose::Meta::TypeCoercion::_compiled_type_coercion, avg 4µs/call
73}
74
75sub has_coercion_for_type {
76 my ($self, $type_name) = @_;
77 my %coercion_map = @{$self->type_coercion_map};
78 exists $coercion_map{$type_name} ? 1 : 0;
79}
80
81sub add_type_coercions {
82 my ($self, @new_coercion_map) = @_;
83
84 my $coercion_map = $self->type_coercion_map;
85 my %has_coercion = @$coercion_map;
86
87 while (@new_coercion_map) {
88 my ($constraint_name, $action) = splice(@new_coercion_map, 0, 2);
89
90 if ( exists $has_coercion{$constraint_name} ) {
91 require Moose;
92 Moose->throw_error("A coercion action already exists for '$constraint_name'")
93 }
94
95 push @{$coercion_map} => ($constraint_name, $action);
96 }
97
98 # and re-compile ...
99 $self->compile_type_coercion;
100}
101
102sub coerce { $_[0]->_compiled_type_coercion->($_[1]) }
103
104
10519µs1;
106
107# ABSTRACT: The Moose Type Coercion metaclass
108
109__END__