[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index][Thread Index][Top&Search][Original]

Re: Devel::DProf patch to allow setting output file



On Wed, 22 Dec 1999 12:46:24 +0100, Haakon Alstadheim wrote:
>> > Hi, I would like to be able to direct the DProf profiler to save its
>> > output to a file I decide. Below is a patch
>> 
>> > +            buffer = getenv("PERL_DPROF_OUTNAME");
>> > +            if (buffer) {
>> > +                output_fname = malloc(strlen(buffer) + 1);
>> > +                if(output_fname == NULL)
>> > +                    croak("Unable to allocate filename 
>> buffer, errno =
>> > %d",errno);
>> > +                strcpy(output_fname,buffer);

FYI.  (Note that this needs other changes to DProf.xs that will be in
v5.5.640, so the patch won't apply cleanly to 5.005_63.)

Sarathy
gsar@ActiveState.com
-----------------------------------8<-----------------------------------
Change 4750 by gsar@auger on 2000/01/02 21:58:02

	make DProf look at $ENV{PERL_DPROF_OUT_FILE_NAME} to make it possible
	to write to a file other than tmon.out (suggested by Haakon Alstadheim
	<Haakon.Alstadheim@sds.no>)

Affected files ...

... //depot/perl/ext/Devel/DProf/DProf.pm#3 edit
... //depot/perl/ext/Devel/DProf/DProf.xs#16 edit

Differences ...

==== //depot/perl/ext/Devel/DProf/DProf.pm#3 (text) ====
Index: perl/ext/Devel/DProf/DProf.pm
--- perl/ext/Devel/DProf/DProf.pm.~1~	Wed Jan  5 11:06:36 2000
+++ perl/ext/Devel/DProf/DProf.pm	Wed Jan  5 11:06:36 2000
@@ -133,6 +133,9 @@
 C<PERL_DPROF_TICKS> sets number of ticks per second on some systems where
 a replacement for times() is used.  Defaults to the value of C<HZ> macro.
 
+C<PERL_DPROF_OUT_FILE_NAME> sets the name of the output file.  If not set,
+defaults to tmon.out.
+
 =head1 BUGS
 
 Builtin functions cannot be measured by Devel::DProf.

==== //depot/perl/ext/Devel/DProf/DProf.xs#16 (text) ====
Index: perl/ext/Devel/DProf/DProf.xs
--- perl/ext/Devel/DProf/DProf.xs.~1~	Wed Jan  5 11:06:36 2000
+++ perl/ext/Devel/DProf/DProf.xs	Wed Jan  5 11:06:36 2000
@@ -69,6 +69,7 @@
 
 typedef struct {
     U32		dprof_ticks;
+    char*	out_file_name;	/* output file (defaults to tmon.out) */
     PerlIO*	fp;		/* pointer to tmon.out file */
     long	TIMES_LOCATION;	/* Where in the file to store the time totals */
     int		SAVE_STACK;	/* How much data to buffer until end of run */
@@ -105,6 +106,7 @@
 prof_state_t g_prof_state;
 
 #define g_dprof_ticks		g_prof_state.dprof_ticks
+#define g_out_file_name		g_prof_state.out_file_name
 #define g_fp			g_prof_state.fp
 #define g_TIMES_LOCATION	g_prof_state.TIMES_LOCATION
 #define g_SAVE_STACK		g_prof_state.SAVE_STACK
@@ -663,10 +665,14 @@
 	    else {
 		g_dprof_ticks = HZ;
 	    }
+
+	    buffer = getenv("PERL_DPROF_OUT_FILE_NAME");
+	    g_out_file_name = savepv(buffer ? buffer : "tmon.out");
 	}
 
-        if ((g_fp = PerlIO_open("tmon.out", "w")) == NULL)
-	    croak("DProf: unable to write tmon.out, errno = %d\n", errno);
+        if ((g_fp = PerlIO_open(g_out_file_name, "w")) == NULL)
+	    croak("DProf: unable to write '%s', errno = %d\n",
+		  g_out_file_name, errno);
 
 	g_default_perldb = PERLDBf_NONAME | PERLDBf_SUB | PERLDBf_GOTO;
 	g_cv_hash = newHV();
End of Patch.


Follow-Ups from:
Ilya Zakharevich <ilya@math.ohio-state.edu>

[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index][Thread Index][Top&Search][Original]