Revision: 864 Author: tim.bunce Date: Mon Sep 28 02:24:24 2009 Log: Added sigexit option to enable a useable profile when the process exits due to a signals. Thanks to Andrew Sterling Hanenkamp for the seed of this idea.
http://code.google.com/p/perl-devel-nytprof/source/detail?r=864 Modified: /trunk/Changes /trunk/lib/Devel/NYTProf/Core.pm /trunk/lib/Devel/NYTProf.pm ======================================= --- /trunk/Changes Sat Sep 19 14:03:28 2009 +++ /trunk/Changes Mon Sep 28 02:24:24 2009 @@ -30,6 +30,9 @@ slowops=2 puts timings into into the package that made the call, e.g., "Foo::CORE:sleep" (note the single colon). + Added sigexit option to enable a useable profile when the process exits due + to a signals. Thanks to Andrew Sterling Hanenkamp for the seed of this idea. + Added inital support for profiling PostgreSQL PL/Perl code via Devel::NYTProf::PgPLPerl module. ======================================= --- /trunk/lib/Devel/NYTProf/Core.pm Thu Jul 16 14:33:54 2009 +++ /trunk/lib/Devel/NYTProf/Core.pm Mon Sep 28 02:24:24 2009 @@ -22,6 +22,13 @@ for my $optval ( $NYTPROF =~ /((?:[^\\:]+|\\.)+)/g) { my ($opt, $val) = $optval =~ /^((?:[^\\=]+|\\.)+)=((?:[^\\=]+| \\.)+)\z/; s/\\(.)/$1/g for $opt, $val; + + if ($opt eq 'sigexit') { + my @sigs = ($val eq '1') ? qw(INT HUP PIPE BUS SEGV) : split(/,/, $val); + $SIG{uc $_} = sub { DB::finish_profile(); exit 1; } for @sigs; + next; # no need to tell the XS code about this + } + DB::set_option($opt, $val); } } ======================================= --- /trunk/lib/Devel/NYTProf.pm Sat Sep 26 15:57:33 2009 +++ /trunk/lib/Devel/NYTProf.pm Mon Sep 28 02:24:24 2009 @@ -450,6 +450,24 @@ See L</CLOCKS> for more information. +=head2 sigexit=1 + +When perl exits normally it runs any code defined in C<END> blocks. +NYTProf defines an END block that finishes profiling and writes out the final +profile data. + +If the process ends due to a signal then END blocks are not executed. +The C<sigexit> option tells NYTProf to catch some signals (e.g. INT, HUP, PIPE, +SEGV, BUS) and ensure a usable by executing: + + DB::finish_profile(); + exit 1; + +You can also specify which signals to catch in this way by listing them, +seperated by commas, as the value of the option (case is not significant): + + sigexit=int,hup + =head1 RUN-TIME CONTROL OF PROFILING You can profile only parts of an application by calling DB::disable_profile() --~--~---------~--~----~------------~-------~--~----~ You've received this message because you are subscribed to the Devel::NYTProf Development User group. Group hosted at: http://groups.google.com/group/develnytprof-dev Project hosted at: http://perl-devel-nytprof.googlecode.com CPAN distribution: http://search.cpan.org/dist/Devel-NYTProf To post, email: [email protected] To unsubscribe, email: [email protected] -~----------~----~----~----~------~----~------~--~---
