File | /usr/local/share/perl/5.10.0/B/Hooks/EndOfScope.pm |
Statements Executed | 84 |
Total Time | 0.0007642 seconds |
Calls | P | F | Exclusive Time |
Inclusive Time |
Subroutine |
---|---|---|---|---|---|
8 | 2 | 2 | 96µs | 233µs | on_scope_end | B::Hooks::EndOfScope::
0 | 0 | 0 | 0s | 0s | BEGIN | B::Hooks::EndOfScope::
0 | 0 | 0 | 0s | 0s | __ANON__[:46] | B::Hooks::EndOfScope::
0 | 0 | 0 | 0s | 0s | __ANON__[:47] | B::Hooks::EndOfScope::
Line | Stmts. | Exclusive Time | Avg. | Code |
---|---|---|---|---|
1 | 3 | 29µs | 10µs | use strict; # spent 10µs making 1 call to strict::import |
2 | 3 | 35µs | 12µs | use warnings; # spent 22µs making 1 call to warnings::import |
3 | ||||
4 | package B::Hooks::EndOfScope; | |||
5 | ||||
6 | 3 | 39µs | 13µs | use 5.008000; |
7 | 3 | 124µs | 41µs | use Variable::Magic; # spent 35µs making 1 call to Exporter::import |
8 | ||||
9 | 1 | 1µs | 1µs | our $VERSION = '0.08'; |
10 | ||||
11 | use Sub::Exporter -setup => { # spent 549µs making 1 call to Sub::Exporter::__ANON__[/usr/local/share/perl/5.10.0/Sub/Exporter.pm:756] | |||
12 | exports => ['on_scope_end'], | |||
13 | groups => { default => ['on_scope_end'] }, | |||
14 | 3 | 217µs | 72µs | }; |
15 | ||||
16 | =head1 NAME | |||
17 | ||||
18 | B::Hooks::EndOfScope - Execute code after a scope finished compilation | |||
19 | ||||
20 | =head1 SYNOPSIS | |||
21 | ||||
22 | on_scope_end { ... }; | |||
23 | ||||
24 | =head1 DESCRIPTION | |||
25 | ||||
26 | This module allows you to execute code when perl finished compiling the | |||
27 | surrounding scope. | |||
28 | ||||
29 | =head1 FUNCTIONS | |||
30 | ||||
31 | =head2 on_scope_end | |||
32 | ||||
33 | on_scope_end { ... }; | |||
34 | ||||
35 | on_scope_end $code; | |||
36 | ||||
37 | Registers C<$code> to be executed after the surrounding scope has been | |||
38 | compiled. | |||
39 | ||||
40 | This is exported by default. See L<Sub::Exporter> on how to customize it. | |||
41 | ||||
42 | =cut | |||
43 | ||||
44 | { | |||
45 | 1 | 800ns | 800ns | my $wiz = Variable::Magic::wizard |
46 | 8 | 11µs | 1µs | data => sub { [$_[1]] }, |
47 | 25 | 113µs | 5µs | free => sub { $_->() for @{ $_[1] }; () }; # spent 10.1ms making 7 calls to namespace::autoclean::__ANON__[/usr/local/share/perl/5.10.0/namespace/autoclean.pm:57], avg 1.44ms/call
# spent 59µs making 1 call to Variable::Magic::wizard
# spent 58µs making 1 call to namespace::clean::__ANON__[/usr/local/share/perl/5.10.0/namespace/clean.pm:246] |
48 | ||||
49 | # spent 233µs (96+137) within B::Hooks::EndOfScope::on_scope_end which was called 8 times, avg 29µs/call:
# 7 times (84µs+101µs) by namespace::autoclean::import or namespace::autoclean::__ANON__[/usr/local/share/perl/5.10.0/namespace/autoclean.pm:57] at line 57 of /usr/local/share/perl/5.10.0/namespace/autoclean.pm, avg 26µs/call
# once (12µs+36µs) by namespace::clean::import or namespace::clean::__ANON__[/usr/local/share/perl/5.10.0/namespace/clean.pm:246] at line 246 of /usr/local/share/perl/5.10.0/namespace/clean.pm | |||
50 | 32 | 145µs | 5µs | my $cb = shift; |
51 | ||||
52 | $^H |= 0x020000; | |||
53 | ||||
54 | if (my $stack = Variable::Magic::getdata %^H, $wiz) { # spent 59µs making 8 calls to Variable::Magic::getdata, avg 7µs/call | |||
55 | push @{ $stack }, $cb; | |||
56 | } | |||
57 | else { | |||
58 | 1 | 42µs | 42µs | Variable::Magic::cast %^H, $wiz, $cb; # spent 77µs making 8 calls to Variable::Magic::cast, avg 10µs/call |
59 | } | |||
60 | } | |||
61 | } | |||
62 | ||||
63 | =head1 SEE ALSO | |||
64 | ||||
65 | L<Sub::Exporter> | |||
66 | ||||
67 | L<Variable::Magic> | |||
68 | ||||
69 | =head1 AUTHOR | |||
70 | ||||
71 | Florian Ragwitz E<lt>rafl@debian.orgE<gt> | |||
72 | ||||
73 | =head1 COPYRIGHT AND LICENSE | |||
74 | ||||
75 | Copyright (c) 2008 Florian Ragwitz | |||
76 | ||||
77 | This module is free software. | |||
78 | ||||
79 | You may distribute this code under the same terms as Perl itself. | |||
80 | ||||
81 | =cut | |||
82 | ||||
83 | 1 | 9µs | 9µs | 1; |