Skip to content

Commit

Permalink
Fix SIGUSR2 on MSWin32 and division by zero #78 PR#79
Browse files Browse the repository at this point in the history
Thanks to @xlat

Closes #78
Closes #79
  • Loading branch information
timbunce committed Mar 6, 2016
1 parent 40e22fc commit bf8186e
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 4 deletions.
7 changes: 4 additions & 3 deletions bin/nytprofhtml
Expand Up @@ -158,7 +158,8 @@ if (defined($opt_lib)) {
lib->import($opt_lib);
}

$SIG{USR2} = \&Carp::cluck;
$SIG{USR2} = \&Carp::cluck
if exists $SIG{USR2}; # some platforms don't have SIGUSR2 (Windows)

my $reporter = new Devel::NYTProf::Reader($opt_file, {
quiet => 0,
Expand Down Expand Up @@ -1022,10 +1023,10 @@ sub package_subinfo_map_to_tm_data {
my $total_time = $si->profile->{attribute}{profiler_duration};
my $incl_time = $si->incl_time;
push @html, sprintf "Inclusive time: %s, %.2f%%",
fmt_time($incl_time), $incl_time/$total_time*100;
fmt_time($incl_time), $total_time ? $incl_time/$total_time*100 : 0;
my $excl_time = $si->excl_time;
push @html, sprintf "Exclusive time: %s, %.2f%%",
fmt_time($excl_time), $excl_time/$total_time*100
fmt_time($excl_time), $total_time ? $excl_time/$total_time*100 : 0
if $excl_time ne $incl_time;

if (my $mrd = $si->recur_max_depth) {
Expand Down
3 changes: 2 additions & 1 deletion bin/nytprofpf
Expand Up @@ -113,7 +113,8 @@ if (defined($opt_lib)) {
lib->import($opt_lib);
}

eval { $SIG{USR2} = \&Carp::cluck }; # some platforms don't have SIGUSR2 (Windows)
$SIG{USR2} = \&Carp::cluck
if exists $SIG{USR2}; # some platforms don't have SIGUSR2 (Windows)

my $reporter = new Devel::NYTProf::Reader($opt_file, {
quiet => 0,
Expand Down

0 comments on commit bf8186e

Please sign in to comment.