| Filename | /Users/ap13/perl5/lib/perl5/darwin-2level/Sub/Name.pm |
| Statements | Executed 15 statements in 371µs |
| Calls | P | F | Exclusive Time |
Inclusive Time |
Subroutine |
|---|---|---|---|---|---|
| 3348 | 7 | 4 | 7.84ms | 7.84ms | Sub::Name::subname (xsub) |
| 1 | 1 | 1 | 38µs | 38µs | Sub::Name::bootstrap (xsub) |
| 1 | 1 | 1 | 26µs | 26µs | Sub::Name::BEGIN@42 |
| 1 | 1 | 1 | 16µs | 25µs | Sub::Name::BEGIN@45 |
| 1 | 1 | 1 | 13µs | 129µs | Sub::Name::BEGIN@49 |
| 1 | 1 | 1 | 12µs | 36µs | Sub::Name::BEGIN@44 |
| 1 | 1 | 1 | 12µs | 92µs | Sub::Name::BEGIN@50 |
| Line | State ments |
Time on line |
Calls | Time in subs |
Code |
|---|---|---|---|---|---|
| 1 | package Sub::Name; | ||||
| 2 | |||||
| 3 | =head1 NAME | ||||
| 4 | |||||
| 5 | Sub::Name - (re)name a sub | ||||
| 6 | |||||
| 7 | =head1 SYNOPSIS | ||||
| 8 | |||||
| 9 | use Sub::Name; | ||||
| 10 | |||||
| 11 | subname $name, $subref; | ||||
| 12 | |||||
| 13 | $subref = subname foo => sub { ... }; | ||||
| 14 | |||||
| 15 | =head1 DESCRIPTION | ||||
| 16 | |||||
| 17 | This module has only one function, which is also exported by default: | ||||
| 18 | |||||
| 19 | =head2 subname NAME, CODEREF | ||||
| 20 | |||||
| 21 | Assigns a new name to referenced sub. If package specification is omitted in | ||||
| 22 | the name, then the current package is used. The return value is the sub. | ||||
| 23 | |||||
| 24 | The name is only used for informative routines (caller, Carp, etc). You won't | ||||
| 25 | be able to actually invoke the sub by the given name. To allow that, you need | ||||
| 26 | to do glob-assignment yourself. | ||||
| 27 | |||||
| 28 | Note that for anonymous closures (subs that reference lexicals declared outside | ||||
| 29 | the sub itself) you can name each instance of the closure differently, which | ||||
| 30 | can be very useful for debugging. | ||||
| 31 | |||||
| 32 | =head1 AUTHOR | ||||
| 33 | |||||
| 34 | Matthijs van Duin <xmath@cpan.org> | ||||
| 35 | |||||
| 36 | Copyright (C) 2004, 2008 Matthijs van Duin. All rights reserved. | ||||
| 37 | This program is free software; you can redistribute it and/or modify | ||||
| 38 | it under the same terms as Perl itself. | ||||
| 39 | |||||
| 40 | =cut | ||||
| 41 | |||||
| 42 | 2 | 98µs | 1 | 26µs | # spent 26µs within Sub::Name::BEGIN@42 which was called:
# once (26µs+0s) by Try::Tiny::BEGIN@1 at line 42 # spent 26µs making 1 call to Sub::Name::BEGIN@42 |
| 43 | |||||
| 44 | 2 | 37µs | 2 | 59µs | # spent 36µs (12+23) within Sub::Name::BEGIN@44 which was called:
# once (12µs+23µs) by Try::Tiny::BEGIN@1 at line 44 # spent 36µs making 1 call to Sub::Name::BEGIN@44
# spent 23µs making 1 call to strict::import |
| 45 | 2 | 55µs | 2 | 33µs | # spent 25µs (16+8) within Sub::Name::BEGIN@45 which was called:
# once (16µs+8µs) by Try::Tiny::BEGIN@1 at line 45 # spent 25µs making 1 call to Sub::Name::BEGIN@45
# spent 8µs making 1 call to warnings::import |
| 46 | |||||
| 47 | 1 | 1µs | our $VERSION = '0.05'; | ||
| 48 | |||||
| 49 | 2 | 42µs | 2 | 245µs | # spent 129µs (13+116) within Sub::Name::BEGIN@49 which was called:
# once (13µs+116µs) by Try::Tiny::BEGIN@1 at line 49 # spent 129µs making 1 call to Sub::Name::BEGIN@49
# spent 116µs making 1 call to base::import |
| 50 | 2 | 111µs | 2 | 173µs | # spent 92µs (12+81) within Sub::Name::BEGIN@50 which was called:
# once (12µs+81µs) by Try::Tiny::BEGIN@1 at line 50 # spent 92µs making 1 call to Sub::Name::BEGIN@50
# spent 81µs making 1 call to base::import |
| 51 | |||||
| 52 | 1 | 1µs | our @EXPORT = qw(subname); | ||
| 53 | 1 | 900ns | our @EXPORT_OK = @EXPORT; | ||
| 54 | |||||
| 55 | 1 | 11µs | 1 | 470µs | bootstrap Sub::Name $VERSION; # spent 470µs making 1 call to DynaLoader::bootstrap |
| 56 | |||||
| 57 | 1 | 14µs | 1; | ||
# spent 38µs within Sub::Name::bootstrap which was called:
# once (38µs+0s) by DynaLoader::bootstrap at line 217 of DynaLoader.pm | |||||
# spent 7.84ms within Sub::Name::subname which was called 3348 times, avg 2µs/call:
# 1285 times (3.51ms+0s) by Try::Tiny::try at line 60 of Try/Tiny.pm, avg 3µs/call
# 1285 times (2.25ms+0s) by Try::Tiny::try at line 61 of Try/Tiny.pm, avg 2µs/call
# 568 times (1.65ms+0s) by Class::MOP::Mixin::HasMethods::add_method at line 75 of Class/MOP/Mixin/HasMethods.pm, avg 3µs/call
# 160 times (309µs+0s) by Moose::Exporter::__ANON__[/Users/ap13/perl5/lib/perl5/darwin-2level/Moose/Exporter.pm:389] at line 384 of Moose/Exporter.pm, avg 2µs/call
# 43 times (107µs+0s) by Class::MOP::Class::add_around_method_modifier at line 1109 of Class/MOP/Class.pm, avg 2µs/call
# 6 times (15µs+0s) by Moose::Exporter::build_import_methods at line 91 of Moose/Exporter.pm, avg 2µs/call
# once (2µs+0s) by Class::MOP::Class::add_before_method_modifier at line 1089 of Class/MOP/Class.pm |