← Index
NYTProf Performance Profile   « line view »
For script/ponapi
  Run on Wed Feb 10 15:51:26 2016
Reported on Thu Feb 11 09:43:10 2016

Filename/usr/local/lib/perl/5.18.2/Moose/Meta/TypeCoercion.pm
StatementsExecuted 36 statements in 666µs
Subroutines
Calls P F Exclusive
Time
Inclusive
Time
Subroutine
1114.52ms96.6msMoose::Meta::TypeCoercion::::BEGIN@8Moose::Meta::TypeCoercion::BEGIN@8
11124µs58µsMoose::Meta::TypeCoercion::::compile_type_coercionMoose::Meta::TypeCoercion::compile_type_coercion
11112µs57µsMoose::Meta::TypeCoercion::::__ANON__[:69]Moose::Meta::TypeCoercion::__ANON__[:69]
11112µs335µsMoose::Meta::TypeCoercion::::newMoose::Meta::TypeCoercion::new
11111µs25µsMoose::Meta::TypeCoercion::::BEGIN@4Moose::Meta::TypeCoercion::BEGIN@4
11110µs177µsMoose::Meta::TypeCoercion::::BEGIN@11Moose::Meta::TypeCoercion::BEGIN@11
1118µs13µsMoose::Meta::TypeCoercion::::BEGIN@5Moose::Meta::TypeCoercion::BEGIN@5
1116µs433µsMoose::Meta::TypeCoercion::::BEGIN@6Moose::Meta::TypeCoercion::BEGIN@6
1115µs5µsMoose::Meta::TypeCoercion::::BEGIN@9Moose::Meta::TypeCoercion::BEGIN@9
0000s0sMoose::Meta::TypeCoercion::::__ANON__[:15]Moose::Meta::TypeCoercion::__ANON__[:15]
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
1package Moose::Meta::TypeCoercion;
212µsour $VERSION = '2.1604';
3
4222µs238µs
# spent 25µs (11+14) within Moose::Meta::TypeCoercion::BEGIN@4 which was called: # once (11µs+14µs) by Moose::BEGIN@26 at line 4
use strict;
# spent 25µs making 1 call to Moose::Meta::TypeCoercion::BEGIN@4 # spent 14µs making 1 call to strict::import
5220µs219µs
# spent 13µs (8+6) within Moose::Meta::TypeCoercion::BEGIN@5 which was called: # once (8µs+6µs) by Moose::BEGIN@26 at line 5
use warnings;
# spent 13µs making 1 call to Moose::Meta::TypeCoercion::BEGIN@5 # spent 6µs making 1 call to warnings::import
6225µs2860µs
# spent 433µs (6+427) within Moose::Meta::TypeCoercion::BEGIN@6 which was called: # once (6µs+427µs) by Moose::BEGIN@26 at line 6
use metaclass;
# spent 433µs making 1 call to Moose::Meta::TypeCoercion::BEGIN@6 # spent 427µs making 1 call to metaclass::import
7
8298µs196.6ms
# spent 96.6ms (4.52+92.0) within Moose::Meta::TypeCoercion::BEGIN@8 which was called: # once (4.52ms+92.0ms) by Moose::BEGIN@26 at line 8
use Moose::Meta::Attribute;
# spent 96.6ms making 1 call to Moose::Meta::TypeCoercion::BEGIN@8
9224µs15µs
# spent 5µs within Moose::Meta::TypeCoercion::BEGIN@9 which was called: # once (5µs+0s) by Moose::BEGIN@26 at line 9
use Moose::Util::TypeConstraints ();
# spent 5µs making 1 call to Moose::Meta::TypeCoercion::BEGIN@9
10
112403µs2345µs
# spent 177µs (10+167) within Moose::Meta::TypeCoercion::BEGIN@11 which was called: # once (10µs+167µs) by Moose::BEGIN@26 at line 11
use Moose::Util 'throw_exception';
# spent 177µs making 1 call to Moose::Meta::TypeCoercion::BEGIN@11 # spent 167µs making 1 call to Sub::Exporter::__ANON__[Sub/Exporter.pm:337]
12
13__PACKAGE__->meta->add_attribute('type_coercion_map' => (
14 reader => 'type_coercion_map',
15 default => sub { [] },
16115µs3303µs Class::MOP::_definition_context(),
# spent 274µs making 1 call to Class::MOP::Mixin::HasAttributes::add_attribute # spent 24µs making 1 call to Moose::Meta::TypeCoercion::meta # spent 5µs making 1 call to Class::MOP::_definition_context
17));
18
1916µs46.16ms__PACKAGE__->meta->add_attribute(
# spent 5.43ms making 1 call to Class::MOP::Mixin::HasAttributes::add_attribute # spent 715µs making 1 call to Moose::Meta::Attribute::new # spent 8µs making 1 call to Moose::Meta::TypeCoercion::meta # spent 4µs making 1 call to Class::MOP::_definition_context
20 Moose::Meta::Attribute->new('type_constraint' => (
21 reader => 'type_constraint',
22 weak_ref => 1,
23 Class::MOP::_definition_context(),
24 ))
25);
26
27# private accessor
2814µs3300µs__PACKAGE__->meta->add_attribute('compiled_type_coercion' => (
# spent 286µs making 1 call to Class::MOP::Mixin::HasAttributes::add_attribute # spent 9µs making 1 call to Moose::Meta::TypeCoercion::meta # spent 5µs making 1 call to Class::MOP::_definition_context
29 accessor => '_compiled_type_coercion',
30 Class::MOP::_definition_context(),
31));
32
33
# spent 335µs (12+323) within Moose::Meta::TypeCoercion::new which was called: # once (12µs+323µs) by Moose::Util::TypeConstraints::_install_type_coercions at line 601 of Moose/Util/TypeConstraints.pm
sub new {
341800ns my $class = shift;
3514µs2266µs my $self = Class::MOP::class_of($class)->new_object(@_);
# spent 260µs making 1 call to Class::MOP::Class::new_object # spent 6µs making 1 call to Class::MOP::class_of
3612µs158µs $self->compile_type_coercion;
# spent 58µs making 1 call to Moose::Meta::TypeCoercion::compile_type_coercion
3714µs return $self;
38}
39
40
# spent 58µs (24+33) within Moose::Meta::TypeCoercion::compile_type_coercion which was called: # once (24µs+33µs) by Moose::Meta::TypeCoercion::new at line 36
sub compile_type_coercion {
411400ns my $self = shift;
4213µs12µs my @coercion_map = @{$self->type_coercion_map};
# spent 2µs making 1 call to Moose::Meta::TypeCoercion::type_coercion_map
431200ns my @coercions;
441600ns while (@coercion_map) {
4511µs my ($constraint_name, $action) = splice(@coercion_map, 0, 2);
4612µs127µs my $type_constraint = ref $constraint_name ? $constraint_name : Moose::Util::TypeConstraints::find_or_parse_type_constraint($constraint_name);
47
481300ns unless ( defined $type_constraint ) {
49 throw_exception( CouldNotFindTypeConstraintToCoerceFrom => constraint_name => $constraint_name,
50 instance => $self
51 );
52 }
53
5413µs11µs push @coercions => [
55 $type_constraint->_compiled_type_constraint,
56 $action
57 ];
58 }
59
# spent 57µs (12+44) within Moose::Meta::TypeCoercion::__ANON__[/usr/local/lib/perl/5.18.2/Moose/Meta/TypeCoercion.pm:69] which was called: # once (12µs+44µs) by PONAPI::Server::ConfigReader::new at line 50 of (eval 45)[Eval/Closure.pm:144]
$self->_compiled_type_coercion(sub {
601400ns my $thing = shift;
611700ns foreach my $coercion (@coercions) {
621700ns my ($constraint, $converter) = @$coercion;
6312µs14µs if ($constraint->($thing)) {
641500ns local $_ = $thing;
6516µs141µs return $converter->($thing);
66 }
67 }
68 return $thing;
6918µs13µs });
70}
71
72sub has_coercion_for_type {
73 my ($self, $type_name) = @_;
74 my %coercion_map = @{$self->type_coercion_map};
75 exists $coercion_map{$type_name} ? 1 : 0;
76}
77
78sub add_type_coercions {
79 my ($self, @new_coercion_map) = @_;
80
81 my $coercion_map = $self->type_coercion_map;
82 my %has_coercion = @$coercion_map;
83
84 while (@new_coercion_map) {
85 my ($constraint_name, $action) = splice(@new_coercion_map, 0, 2);
86
87 if ( exists $has_coercion{$constraint_name} ) {
88 throw_exception( CoercionAlreadyExists => constraint_name => $constraint_name,
89 instance => $self
90 );
91 }
92
93 push @{$coercion_map} => ($constraint_name, $action);
94 }
95
96 # and re-compile ...
97 $self->compile_type_coercion;
98}
99
100sub coerce { $_[0]->_compiled_type_coercion->($_[1]) }
101
102
10318µs1;
104
105# ABSTRACT: The Moose Type Coercion metaclass
106
107__END__