line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
# vim: ts=8 sw=4 expandtab: |
2
|
|
|
|
|
|
|
########################################################## |
3
|
|
|
|
|
|
|
# This script is part of the Devel::NYTProf distribution |
4
|
|
|
|
|
|
|
# |
5
|
|
|
|
|
|
|
# Copyright, contact and other information can be found |
6
|
|
|
|
|
|
|
# at the bottom of this file, or by going to: |
7
|
|
|
|
|
|
|
# http://metacpan.org/release/Devel-NYTProf/ |
8
|
|
|
|
|
|
|
# |
9
|
|
|
|
|
|
|
########################################################### |
10
|
|
|
|
|
|
|
package Devel::NYTProf::Core; |
11
|
|
|
|
|
|
|
|
12
|
|
|
|
|
|
|
|
13
|
54
|
|
|
54
|
|
4556
|
use XSLoader; |
|
54
|
|
|
1
|
|
108
|
|
|
54
|
|
|
|
|
20033
|
|
|
1
|
|
|
|
|
777
|
|
|
1
|
|
|
|
|
3
|
|
|
1
|
|
|
|
|
327
|
|
14
|
|
|
|
|
|
|
|
15
|
|
|
|
|
|
|
our $VERSION = '6.13'; # increment with XS changes too |
16
|
|
|
|
|
|
|
|
17
|
|
|
|
|
|
|
XSLoader::load('Devel::NYTProf', $VERSION); |
18
|
|
|
|
|
|
|
|
19
|
|
|
|
|
|
|
# Fudging for https://rt.cpan.org/Ticket/Display.html?id=82256 |
20
|
|
|
|
|
|
|
$Devel::NYTProf::StrEvalTestPad = ($] <= 5.017004) ? ";\n" : ""; |
21
|
|
|
|
|
|
|
|
22
|
|
|
|
|
|
|
if (my $NYTPROF = $ENV{NYTPROF}) { |
23
|
|
|
|
|
|
|
for my $optval ( $NYTPROF =~ /((?:[^\\:]+|\\.)+)/g) { |
24
|
|
|
|
|
|
|
my ($opt, $val) = $optval =~ /^((?:[^\\=]+|\\.)+)=((?:[^\\=]+|\\.)+)\z/; |
25
|
|
|
|
|
|
|
s/\\(.)/$1/g for $opt, $val; |
26
|
|
|
|
|
|
|
|
27
|
|
|
|
|
|
|
if ($opt eq 'sigexit') { |
28
|
|
|
|
|
|
|
# Intercept sudden process exit caused by signals |
29
|
|
|
|
|
|
|
my @sigs = ($val eq '1') ? qw(INT HUP PIPE BUS SEGV) : split(/,/, $val); |
30
|
|
|
|
|
|
|
$SIG{uc $_} = sub { DB::finish_profile(); exit 1; } for @sigs; |
31
|
|
|
|
|
|
|
next; # no need to tell the XS code about this |
32
|
|
|
|
|
|
|
} |
33
|
|
|
|
|
|
|
|
34
|
|
|
|
|
|
|
if ($opt eq 'posix_exit') { |
35
|
|
|
|
|
|
|
# Intercept sudden process exit caused by POSIX::_exit() call. |
36
|
|
|
|
|
|
|
# Should only be needed if subs=0. We delay till after profiling |
37
|
|
|
|
|
|
|
# has probably started to minimize the effect on the profile. |
38
|
|
|
|
|
|
|
eval q{ INIT { |
39
|
|
|
|
|
|
|
require POSIX; |
40
|
|
|
|
|
|
|
my $orig = \&POSIX::_exit; |
41
|
|
|
|
|
|
|
local $^W = 0; # avoid sub redef warning |
42
|
|
|
|
|
|
|
*POSIX::_exit = sub { DB::finish_profile(); $orig->(@_) }; |
43
|
|
|
|
|
|
|
} 1 } or die if $val; |
44
|
|
|
|
|
|
|
next; # no need to tell the XS code about this |
45
|
|
|
|
|
|
|
} |
46
|
|
|
|
|
|
|
|
47
|
|
|
|
|
|
|
DB::set_option($opt, $val); |
48
|
|
|
|
|
|
|
} |
49
|
|
|
|
|
|
|
} |
50
|
|
|
|
|
|
|
|
51
|
|
|
|
|
|
|
1; |
52
|
|
|
|
|
|
|
|
53
|
|
|
|
|
|
|
__END__ |