Filename | /2home/ss5/perl5/perlbrew/perls/perl-5.12.3/lib/site_perl/5.12.3/x86_64-linux/Devel/GlobalDestruction.pm |
Statements | Executed 15 statements in 401µs |
Calls | P | F | Exclusive Time |
Inclusive Time |
Subroutine |
---|---|---|---|---|---|
3 | 1 | 1 | 15µs | 15µs | in_global_destruction (xsub) | Devel::GlobalDestruction::
1 | 1 | 1 | 13µs | 15µs | BEGIN@3 | Devel::GlobalDestruction::
1 | 1 | 1 | 12µs | 399µs | BEGIN@8 | Devel::GlobalDestruction::
1 | 1 | 1 | 6µs | 13µs | BEGIN@4 | Devel::GlobalDestruction::
Line | State ments |
Time on line |
Calls | Time in subs |
Code |
---|---|---|---|---|---|
1 | package Devel::GlobalDestruction; | ||||
2 | |||||
3 | 3 | 16µs | 2 | 17µs | # spent 15µs (13+2) within Devel::GlobalDestruction::BEGIN@3 which was called:
# once (13µs+2µs) by Class::MOP::Package::BEGIN@15 at line 3 # spent 15µs making 1 call to Devel::GlobalDestruction::BEGIN@3
# spent 2µs making 1 call to strict::import |
4 | 3 | 37µs | 2 | 21µs | # spent 13µs (6+7) within Devel::GlobalDestruction::BEGIN@4 which was called:
# once (6µs+7µs) by Class::MOP::Package::BEGIN@15 at line 4 # spent 13µs making 1 call to Devel::GlobalDestruction::BEGIN@4
# spent 7µs making 1 call to warnings::import |
5 | |||||
6 | 1 | 500ns | our $VERSION = '0.05'; | ||
7 | |||||
8 | 1 | 388µs | # spent 399µs (12+388) within Devel::GlobalDestruction::BEGIN@8 which was called:
# once (12µs+388µs) by Class::MOP::Package::BEGIN@15 at line 11 # spent 388µs making 1 call to Sub::Exporter::__ANON__[Sub/Exporter.pm:756] | ||
9 | exports => [ qw(in_global_destruction) ], | ||||
10 | groups => { default => [ -all ] }, | ||||
11 | 3 | 98µs | 1 | 399µs | }; # spent 399µs making 1 call to Devel::GlobalDestruction::BEGIN@8 |
12 | |||||
13 | 1 | 900ns | if (defined ${^GLOBAL_PHASE}) { | ||
14 | eval 'sub in_global_destruction () { ${^GLOBAL_PHASE} eq q[DESTRUCT] }'; | ||||
15 | } | ||||
16 | elsif (eval { | ||||
17 | 1 | 600ns | require XSLoader; | ||
18 | 1 | 240µs | 1 | 234µs | XSLoader::load(__PACKAGE__, $VERSION); # spent 234µs making 1 call to XSLoader::load |
19 | 1 | 900ns | 1; | ||
20 | }) { | ||||
21 | # the eval already installed everything, nothing to do | ||||
22 | } | ||||
23 | else { | ||||
24 | eval <<'PP_IGD' or die $@; | ||||
25 | |||||
26 | my ($in_global_destruction, $before_is_installed); | ||||
27 | |||||
28 | sub in_global_destruction { $in_global_destruction } | ||||
29 | |||||
30 | END { | ||||
31 | # SpeedyCGI runs END blocks every cycle but somehow keeps object instances | ||||
32 | # hence lying about it seems reasonable...ish | ||||
33 | $in_global_destruction = 1 unless $CGI::SpeedyCGI::i_am_speedy; | ||||
34 | } | ||||
35 | |||||
36 | # threads do not execute the global ENDs (it would be stupid). However | ||||
37 | # one can register a new END via simple string eval within a thread, and | ||||
38 | # achieve the same result. A logical place to do this would be CLONE, which | ||||
39 | # is claimed to run in the context of the new thread. However this does | ||||
40 | # not really seem to be the case - any END evaled in a CLONE is ignored :( | ||||
41 | # Hence blatantly hooking threads::create | ||||
42 | |||||
43 | if ($INC{'threads.pm'}) { | ||||
44 | my $orig_create = threads->can('create'); | ||||
45 | no warnings 'redefine'; | ||||
46 | *threads::create = sub { | ||||
47 | { local $@; eval 'END { $in_global_destruction = 1 }' }; | ||||
48 | goto $orig_create; | ||||
49 | }; | ||||
50 | $before_is_installed = 1; | ||||
51 | } | ||||
52 | |||||
53 | # just in case threads got loaded after us (silly) | ||||
54 | sub CLONE { | ||||
55 | unless ($before_is_installed) { | ||||
56 | require Carp; | ||||
57 | Carp::croak("You must load the 'threads' module before @{[ __PACKAGE__ ]}"); | ||||
58 | } | ||||
59 | } | ||||
60 | |||||
61 | 1; # keep eval happy | ||||
62 | |||||
63 | PP_IGD | ||||
64 | |||||
65 | } | ||||
66 | |||||
67 | 1 | 7µs | 1; # keep require happy | ||
68 | |||||
69 | |||||
70 | __END__ | ||||
# spent 15µs within Devel::GlobalDestruction::in_global_destruction which was called 3 times, avg 5µs/call:
# 3 times (15µs+0s) by Moose::Object::__ANON__[/2home/ss5/perl5/perlbrew/perls/perl-5.12.3/lib/site_perl/5.12.3/x86_64-linux/Moose/Object.pm:99] at line 98 of Moose/Object.pm, avg 5µs/call |