← Index
NYTProf Performance Profile   « block view • line view • sub view »
For bin/pan_genome_post_analysis
  Run on Fri Mar 27 11:43:32 2015
Reported on Fri Mar 27 11:45:26 2015

Filename/Users/ap13/perl5/lib/perl5/darwin-2level/Moose/Meta/TypeCoercion.pm
StatementsExecuted 17 statements in 753µs
Subroutines
Calls P F Exclusive
Time
Inclusive
Time
Subroutine
1116.14ms97.4msMoose::Meta::TypeCoercion::::BEGIN@8Moose::Meta::TypeCoercion::BEGIN@8
11116µs34µsMoose::Meta::TypeCoercion::::BEGIN@4Moose::Meta::TypeCoercion::BEGIN@4
11110µs210µsMoose::Meta::TypeCoercion::::BEGIN@11Moose::Meta::TypeCoercion::BEGIN@11
1119µs16µsMoose::Meta::TypeCoercion::::BEGIN@5Moose::Meta::TypeCoercion::BEGIN@5
1118µs619µsMoose::Meta::TypeCoercion::::BEGIN@6Moose::Meta::TypeCoercion::BEGIN@6
1116µs6µsMoose::Meta::TypeCoercion::::BEGIN@9Moose::Meta::TypeCoercion::BEGIN@9
0000s0sMoose::Meta::TypeCoercion::::__ANON__[:15]Moose::Meta::TypeCoercion::__ANON__[:15]
0000s0sMoose::Meta::TypeCoercion::::__ANON__[:69]Moose::Meta::TypeCoercion::__ANON__[:69]
0000s0sMoose::Meta::TypeCoercion::::add_type_coercionsMoose::Meta::TypeCoercion::add_type_coercions
0000s0sMoose::Meta::TypeCoercion::::coerceMoose::Meta::TypeCoercion::coerce
0000s0sMoose::Meta::TypeCoercion::::compile_type_coercionMoose::Meta::TypeCoercion::compile_type_coercion
0000s0sMoose::Meta::TypeCoercion::::has_coercion_for_typeMoose::Meta::TypeCoercion::has_coercion_for_type
0000s0sMoose::Meta::TypeCoercion::::newMoose::Meta::TypeCoercion::new
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;
21800nsour $VERSION = '2.1403';
3
4225µs252µs
# spent 34µs (16+18) within Moose::Meta::TypeCoercion::BEGIN@4 which was called: # once (16µs+18µs) by Moose::BEGIN@26 at line 4
use strict;
# spent 34µs making 1 call to Moose::Meta::TypeCoercion::BEGIN@4 # spent 18µs making 1 call to strict::import
5222µs223µs
# spent 16µs (9+7) within Moose::Meta::TypeCoercion::BEGIN@5 which was called: # once (9µs+7µs) by Moose::BEGIN@26 at line 5
use warnings;
# spent 16µs making 1 call to Moose::Meta::TypeCoercion::BEGIN@5 # spent 7µs making 1 call to warnings::import
6227µs21.23ms
# spent 619µs (8+612) within Moose::Meta::TypeCoercion::BEGIN@6 which was called: # once (8µs+612µs) by Moose::BEGIN@26 at line 6
use metaclass;
# spent 619µs making 1 call to Moose::Meta::TypeCoercion::BEGIN@6 # spent 612µs making 1 call to metaclass::import
7
82142µs197.4ms
# spent 97.4ms (6.14+91.3) within Moose::Meta::TypeCoercion::BEGIN@8 which was called: # once (6.14ms+91.3ms) by Moose::BEGIN@26 at line 8
use Moose::Meta::Attribute;
# spent 97.4ms making 1 call to Moose::Meta::TypeCoercion::BEGIN@8
9228µs16µs
# spent 6µs within Moose::Meta::TypeCoercion::BEGIN@9 which was called: # once (6µs+0s) by Moose::BEGIN@26 at line 9
use Moose::Util::TypeConstraints ();
# spent 6µs making 1 call to Moose::Meta::TypeCoercion::BEGIN@9
10
112456µs2409µs
# spent 210µs (10+200) within Moose::Meta::TypeCoercion::BEGIN@11 which was called: # once (10µs+200µs) by Moose::BEGIN@26 at line 11
use Moose::Util 'throw_exception';
# spent 210µs making 1 call to Moose::Meta::TypeCoercion::BEGIN@11 # spent 200µ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 { [] },
1618µs3395µs Class::MOP::_definition_context(),
# spent 368µs making 1 call to Class::MOP::Mixin::HasAttributes::add_attribute # spent 20µs making 1 call to Moose::Meta::TypeCoercion::meta # spent 6µs making 1 call to Class::MOP::_definition_context
17));
18
19112µs43.81ms__PACKAGE__->meta->add_attribute(
# spent 2.74ms making 1 call to Class::MOP::Mixin::HasAttributes::add_attribute # spent 1.05ms making 1 call to Moose::Meta::Attribute::new # spent 12µs making 1 call to Moose::Meta::TypeCoercion::meta # spent 6µ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
2818µs3514µs__PACKAGE__->meta->add_attribute('compiled_type_coercion' => (
# spent 492µs making 1 call to Class::MOP::Mixin::HasAttributes::add_attribute # spent 14µs making 1 call to Moose::Meta::TypeCoercion::meta # spent 9µs making 1 call to Class::MOP::_definition_context
29 accessor => '_compiled_type_coercion',
30 Class::MOP::_definition_context(),
31));
32
33sub new {
34 my $class = shift;
35 my $self = Class::MOP::class_of($class)->new_object(@_);
36 $self->compile_type_coercion;
37 return $self;
38}
39
40sub compile_type_coercion {
41 my $self = shift;
42 my @coercion_map = @{$self->type_coercion_map};
43 my @coercions;
44 while (@coercion_map) {
45 my ($constraint_name, $action) = splice(@coercion_map, 0, 2);
46 my $type_constraint = ref $constraint_name ? $constraint_name : Moose::Util::TypeConstraints::find_or_parse_type_constraint($constraint_name);
47
48 unless ( defined $type_constraint ) {
49 throw_exception( CouldNotFindTypeConstraintToCoerceFrom => constraint_name => $constraint_name,
50 instance => $self
51 );
52 }
53
54 push @coercions => [
55 $type_constraint->_compiled_type_constraint,
56 $action
57 ];
58 }
59 $self->_compiled_type_coercion(sub {
60 my $thing = shift;
61 foreach my $coercion (@coercions) {
62 my ($constraint, $converter) = @$coercion;
63 if ($constraint->($thing)) {
64 local $_ = $thing;
65 return $converter->($thing);
66 }
67 }
68 return $thing;
69 });
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
103125µs1;
104
105# ABSTRACT: The Moose Type Coercion metaclass
106
107__END__