| Filename | /home/hinrik/perl5/perlbrew/perls/perl-5.13.5/lib/site_perl/5.13.5/MouseX/Getopt/OptionTypeMap.pm |
| Statements | Executed 122 statements in 1.03ms |
| Calls | P | F | Exclusive Time |
Inclusive Time |
Subroutine |
|---|---|---|---|---|---|
| 22 | 1 | 1 | 219µs | 279µs | MouseX::Getopt::OptionTypeMap::get_option_type |
| 22 | 1 | 1 | 205µs | 272µs | MouseX::Getopt::OptionTypeMap::has_option_type |
| 1 | 1 | 1 | 18µs | 18µs | MouseX::Getopt::OptionTypeMap::BEGIN@2 |
| 1 | 1 | 1 | 13µs | 432µs | MouseX::Getopt::OptionTypeMap::BEGIN@10 |
| 1 | 1 | 1 | 13µs | 74µs | MouseX::Getopt::OptionTypeMap::BEGIN@75 |
| 1 | 1 | 1 | 12µs | 69µs | MouseX::Getopt::OptionTypeMap::BEGIN@11 |
| 1 | 1 | 1 | 11µs | 55µs | MouseX::Getopt::OptionTypeMap::BEGIN@76 |
| 1 | 1 | 1 | 5µs | 5µs | MouseX::Getopt::OptionTypeMap::BEGIN@5 |
| 0 | 0 | 0 | 0s | 0s | MouseX::Getopt::OptionTypeMap::add_option_type_to_map |
| Line | State ments |
Time on line |
Calls | Time in subs |
Code |
|---|---|---|---|---|---|
| 1 | package MouseX::Getopt::OptionTypeMap; | ||||
| 2 | # spent 18µs within MouseX::Getopt::OptionTypeMap::BEGIN@2 which was called:
# once (18µs+0s) by MouseX::Getopt::Basic::BEGIN@12 at line 4 | ||||
| 3 | 1 | 16µs | $MouseX::Getopt::OptionTypeMap::AUTHORITY = 'cpan:STEVAN'; | ||
| 4 | 1 | 27µs | 1 | 18µs | } # spent 18µs making 1 call to MouseX::Getopt::OptionTypeMap::BEGIN@2 |
| 5 | # spent 5µs within MouseX::Getopt::OptionTypeMap::BEGIN@5 which was called:
# once (5µs+0s) by MouseX::Getopt::Basic::BEGIN@12 at line 7 | ||||
| 6 | 1 | 6µs | $MouseX::Getopt::OptionTypeMap::VERSION = '0.33'; | ||
| 7 | 1 | 20µs | 1 | 5µs | } # spent 5µs making 1 call to MouseX::Getopt::OptionTypeMap::BEGIN@5 |
| 8 | # ABSTRACT: Storage for the option to type mappings | ||||
| 9 | |||||
| 10 | 2 | 31µs | 2 | 851µs | # spent 432µs (13+419) within MouseX::Getopt::OptionTypeMap::BEGIN@10 which was called:
# once (13µs+419µs) by MouseX::Getopt::Basic::BEGIN@12 at line 10 # spent 432µs making 1 call to MouseX::Getopt::OptionTypeMap::BEGIN@10
# spent 419µs making 1 call to Mouse::Exporter::do_import |
| 11 | 2 | 284µs | 2 | 126µs | # spent 69µs (12+57) within MouseX::Getopt::OptionTypeMap::BEGIN@11 which was called:
# once (12µs+57µs) by MouseX::Getopt::Basic::BEGIN@12 at line 11 # spent 69µs making 1 call to MouseX::Getopt::OptionTypeMap::BEGIN@11
# spent 57µs making 1 call to Mouse::Exporter::do_import |
| 12 | |||||
| 13 | 1 | 4µs | my %option_type_map = ( | ||
| 14 | 'Bool' => '!', | ||||
| 15 | 'Str' => '=s', | ||||
| 16 | 'Int' => '=i', | ||||
| 17 | 'Num' => '=f', | ||||
| 18 | 'ArrayRef' => '=s@', | ||||
| 19 | 'HashRef' => '=s%', | ||||
| 20 | ); | ||||
| 21 | |||||
| 22 | # spent 272µs (205+67) within MouseX::Getopt::OptionTypeMap::has_option_type which was called 22 times, avg 12µs/call:
# 22 times (205µs+67µs) by MouseX::Getopt::Basic::_attrs_to_options at line 209 of MouseX/Getopt/Basic.pm, avg 12µs/call | ||||
| 23 | 22 | 29µs | my (undef, $type_or_name) = @_; | ||
| 24 | |||||
| 25 | 22 | 258µs | 44 | 67µs | return 1 if exists $option_type_map{blessed($type_or_name) ? $type_or_name->name : $type_or_name}; # spent 35µs making 22 calls to Scalar::Util::blessed, avg 2µs/call
# spent 32µs making 22 calls to Mouse::Meta::TypeConstraint::name, avg 1µs/call |
| 26 | |||||
| 27 | my $current = blessed($type_or_name) ? $type_or_name : find_type_constraint($type_or_name); | ||||
| 28 | |||||
| 29 | (defined $current) | ||||
| 30 | || confess "Could not find the type constraint for '$type_or_name'"; | ||||
| 31 | |||||
| 32 | while (my $parent = $current->parent) { | ||||
| 33 | return 1 if exists $option_type_map{$parent->name}; | ||||
| 34 | $current = $parent; | ||||
| 35 | } | ||||
| 36 | |||||
| 37 | return 0; | ||||
| 38 | } | ||||
| 39 | |||||
| 40 | # spent 279µs (219+60) within MouseX::Getopt::OptionTypeMap::get_option_type which was called 22 times, avg 13µs/call:
# 22 times (219µs+60µs) by MouseX::Getopt::Basic::_attrs_to_options at line 209 of MouseX/Getopt/Basic.pm, avg 13µs/call | ||||
| 41 | 22 | 27µs | my (undef, $type_or_name) = @_; | ||
| 42 | |||||
| 43 | 22 | 183µs | 44 | 60µs | my $name = blessed($type_or_name) ? $type_or_name->name : $type_or_name; # spent 31µs making 22 calls to Scalar::Util::blessed, avg 1µs/call
# spent 29µs making 22 calls to Mouse::Meta::TypeConstraint::name, avg 1µs/call |
| 44 | |||||
| 45 | 22 | 86µs | return $option_type_map{$name} if exists $option_type_map{$name}; | ||
| 46 | |||||
| 47 | my $current = ref $type_or_name ? $type_or_name : find_type_constraint($type_or_name); | ||||
| 48 | |||||
| 49 | (defined $current) | ||||
| 50 | || confess "Could not find the type constraint for '$type_or_name'"; | ||||
| 51 | |||||
| 52 | while ( $current = $current->parent ) { | ||||
| 53 | return $option_type_map{$current->name} | ||||
| 54 | if exists $option_type_map{$current->name}; | ||||
| 55 | } | ||||
| 56 | |||||
| 57 | return; | ||||
| 58 | } | ||||
| 59 | |||||
| 60 | sub add_option_type_to_map { | ||||
| 61 | my (undef, $type_name, $option_string) = @_; | ||||
| 62 | (defined $type_name && defined $option_string) | ||||
| 63 | || confess "You must supply both a type name and an option string"; | ||||
| 64 | |||||
| 65 | if ( blessed($type_name) ) { | ||||
| 66 | $type_name = $type_name->name; | ||||
| 67 | } else { | ||||
| 68 | (find_type_constraint($type_name)) | ||||
| 69 | || confess "The type constraint '$type_name' does not exist"; | ||||
| 70 | } | ||||
| 71 | |||||
| 72 | $option_type_map{$type_name} = $option_string; | ||||
| 73 | } | ||||
| 74 | |||||
| 75 | 2 | 33µs | 2 | 136µs | # spent 74µs (13+62) within MouseX::Getopt::OptionTypeMap::BEGIN@75 which was called:
# once (13µs+62µs) by MouseX::Getopt::Basic::BEGIN@12 at line 75 # spent 74µs making 1 call to MouseX::Getopt::OptionTypeMap::BEGIN@75
# spent 62µs making 1 call to Mouse::Exporter::do_unimport |
| 76 | 2 | 21µs | 2 | 98µs | # spent 55µs (11+44) within MouseX::Getopt::OptionTypeMap::BEGIN@76 which was called:
# once (11µs+44µs) by MouseX::Getopt::Basic::BEGIN@12 at line 76 # spent 55µs making 1 call to MouseX::Getopt::OptionTypeMap::BEGIN@76
# spent 44µs making 1 call to Mouse::Exporter::do_unimport |
| 77 | |||||
| 78 | 1 | 4µs | 1; | ||
| 79 | |||||
| 80 | |||||
| 81 | __END__ |