Commit 066dbe78 authored by simonmar's avatar simonmar
Browse files

[project @ 2000-04-19 12:42:48 by simonmar]

- generate the heap profiling into <prog>.hp, as advertised
- clean up RtsFlags a bit
parent 22bcecc9
/* ----------------------------------------------------------------------------- /* -----------------------------------------------------------------------------
* $Id: ProfHeap.c,v 1.11 2000/04/05 15:32:08 simonmar Exp $ * $Id: ProfHeap.c,v 1.12 2000/04/19 12:42:48 simonmar Exp $
* *
* (c) The GHC Team, 1998-2000 * (c) The GHC Team, 1998-2000
* *
...@@ -32,8 +32,6 @@ static void clear_table_data(void); ...@@ -32,8 +32,6 @@ static void clear_table_data(void);
static void fprint_data(FILE *fp); static void fprint_data(FILE *fp);
#endif #endif
char prof_filename[128]; /* urk */
/* ----------------------------------------------------------------------------- /* -----------------------------------------------------------------------------
* Hash tables. * Hash tables.
* *
...@@ -148,7 +146,7 @@ reportCtrResid(FILE *fp) ...@@ -148,7 +146,7 @@ reportCtrResid(FILE *fp)
/* -------------------------------------------------------------------------- */ /* -------------------------------------------------------------------------- */
#ifdef DEBUG_HEAP_PROF #ifdef DEBUG_HEAP_PROF
FILE *prof_file; FILE *hp_file;
void initProfiling1( void ) void initProfiling1( void )
{ {
...@@ -172,14 +170,14 @@ initHeapProfiling(void) ...@@ -172,14 +170,14 @@ initHeapProfiling(void)
return 0; return 0;
} }
fprintf(prof_file, "JOB \"%s\"\n", prog_argv[0]); fprintf(hp_file, "JOB \"%s\"\n", prog_argv[0]);
fprintf(prof_file, "DATE \"%s\"\n", time_str()); fprintf(hp_file, "DATE \"%s\"\n", time_str());
fprintf(prof_file, "SAMPLE_UNIT \"seconds\"\n"); fprintf(hp_file, "SAMPLE_UNIT \"seconds\"\n");
fprintf(prof_file, "VALUE_UNIT \"bytes\"\n"); fprintf(hp_file, "VALUE_UNIT \"bytes\"\n");
fprintf(prof_file, "BEGIN_SAMPLE 0.00\n"); fprintf(hp_file, "BEGIN_SAMPLE 0.00\n");
fprintf(prof_file, "END_SAMPLE 0.00\n"); fprintf(hp_file, "END_SAMPLE 0.00\n");
#ifdef DEBUG_HEAP_PROF #ifdef DEBUG_HEAP_PROF
DEBUG_LoadSymbols(prog_argv[0]); DEBUG_LoadSymbols(prog_argv[0]);
...@@ -203,9 +201,9 @@ endHeapProfiling(void) ...@@ -203,9 +201,9 @@ endHeapProfiling(void)
} }
seconds = mut_user_time(); seconds = mut_user_time();
fprintf(prof_file, "BEGIN_SAMPLE %0.2f\n", seconds); fprintf(hp_file, "BEGIN_SAMPLE %0.2f\n", seconds);
fprintf(prof_file, "END_SAMPLE %0.2f\n", seconds); fprintf(hp_file, "END_SAMPLE %0.2f\n", seconds);
fclose(prof_file); fclose(hp_file);
} }
#ifdef DEBUG_HEAP_PROF #ifdef DEBUG_HEAP_PROF
...@@ -483,7 +481,7 @@ heapCensus(void) ...@@ -483,7 +481,7 @@ heapCensus(void)
bd = g0s0->to_space; bd = g0s0->to_space;
time = mut_user_time_during_GC(); time = mut_user_time_during_GC();
fprintf(prof_file, "BEGIN_SAMPLE %0.2f\n", time); fprintf(hp_file, "BEGIN_SAMPLE %0.2f\n", time);
while (bd != NULL) { while (bd != NULL) {
p = bd->start; p = bd->start;
...@@ -602,10 +600,10 @@ heapCensus(void) ...@@ -602,10 +600,10 @@ heapCensus(void)
#ifdef DEBUG_HEAP_PROF #ifdef DEBUG_HEAP_PROF
switch (RtsFlags.ProfFlags.doHeapProfile) { switch (RtsFlags.ProfFlags.doHeapProfile) {
case HEAP_BY_INFOPTR: case HEAP_BY_INFOPTR:
fprint_data(prof_file); fprint_data(hp_file);
break; break;
case HEAP_BY_CLOSURE_TYPE: case HEAP_BY_CLOSURE_TYPE:
fprint_closure_types(prof_file); fprint_closure_types(hp_file);
break; break;
} }
#endif #endif
...@@ -613,19 +611,19 @@ heapCensus(void) ...@@ -613,19 +611,19 @@ heapCensus(void)
#ifdef PROFILING #ifdef PROFILING
switch (RtsFlags.ProfFlags.doHeapProfile) { switch (RtsFlags.ProfFlags.doHeapProfile) {
case HEAP_BY_CCS: case HEAP_BY_CCS:
reportCCSResid(prof_file,CCS_MAIN); reportCCSResid(hp_file,CCS_MAIN);
break; break;
case HEAP_BY_MOD: case HEAP_BY_MOD:
case HEAP_BY_DESCR: case HEAP_BY_DESCR:
case HEAP_BY_TYPE: case HEAP_BY_TYPE:
reportCtrResid(prof_file); reportCtrResid(hp_file);
break; break;
default: default:
barf("heapCensus; doHeapProfile"); barf("heapCensus; doHeapProfile");
} }
#endif #endif
fprintf(prof_file, "END_SAMPLE %0.2f\n", time); fprintf(hp_file, "END_SAMPLE %0.2f\n", time);
} }
#endif /* PROFILING || DEBUG_HEAP_PROF */ #endif /* PROFILING || DEBUG_HEAP_PROF */
......
/* ----------------------------------------------------------------------------- /* -----------------------------------------------------------------------------
* $Id: Profiling.c,v 1.18 2000/04/05 15:21:28 simonmar Exp $ * $Id: Profiling.c,v 1.19 2000/04/19 12:42:48 simonmar Exp $
* *
* (c) The GHC Team, 1998-2000 * (c) The GHC Team, 1998-2000
* *
...@@ -46,11 +46,14 @@ rtsBool time_profiling = rtsFalse; ...@@ -46,11 +46,14 @@ rtsBool time_profiling = rtsFalse;
*/ */
static lnat total_alloc, total_prof_ticks; static lnat total_alloc, total_prof_ticks;
/* Globals for opening the profiling log file /* Globals for opening the profiling log file(s)
*/ */
static char *prof_filename; /* prof report file name = <program>.prof */ static char *prof_filename; /* prof report file name = <program>.prof */
FILE *prof_file; FILE *prof_file;
static char *hp_filename; /* heap profile (hp2ps style) log file */
FILE *hp_file;
/* The Current Cost Centre Stack (for attributing costs) /* The Current Cost Centre Stack (for attributing costs)
*/ */
CostCentreStack *CCCS; CostCentreStack *CCCS;
...@@ -244,6 +247,20 @@ initProfilingLogFile(void) ...@@ -244,6 +247,20 @@ initProfilingLogFile(void)
} }
} }
} }
if (RtsFlags.ProfFlags.doHeapProfile) {
/* Initialise the log file name */
hp_filename = stgMallocBytes(strlen(prog_argv[0]) + 6, "initProfiling");
sprintf(hp_filename, "%s.hp", prog_argv[0]);
/* open the log file */
if ((hp_file = fopen(hp_filename, "w")) == NULL) {
fprintf(stderr, "Can't open profiling report file %s\n",
hp_filename);
RtsFlags.ProfFlags.doHeapProfile = 0;
return;
}
}
} }
void void
......
/* ----------------------------------------------------------------------------- /* -----------------------------------------------------------------------------
* $Id: Profiling.h,v 1.1 2000/04/03 15:54:49 simonmar Exp $ * $Id: Profiling.h,v 1.2 2000/04/19 12:42:48 simonmar Exp $
* *
* (c) The GHC Team, 1998-2000 * (c) The GHC Team, 1998-2000
* *
...@@ -13,6 +13,7 @@ void initProfiling2 ( void ); ...@@ -13,6 +13,7 @@ void initProfiling2 ( void );
void endProfiling ( void ); void endProfiling ( void );
extern FILE *prof_file; extern FILE *prof_file;
extern FILE *hp_file;
#endif #endif
#ifdef PROFILING #ifdef PROFILING
......
/* ----------------------------------------------------------------------------- /* -----------------------------------------------------------------------------
* $Id: RtsFlags.c,v 1.29 2000/04/03 15:54:50 simonmar Exp $ * $Id: RtsFlags.c,v 1.30 2000/04/19 12:42:48 simonmar Exp $
* *
* (c) The AQUA Project, Glasgow University, 1994-1997 * (c) The AQUA Project, Glasgow University, 1994-1997
* (c) The GHC Team, 1998-1999 * (c) The GHC Team, 1998-1999
...@@ -31,12 +31,8 @@ ...@@ -31,12 +31,8 @@
#include "Itimer.h" #include "Itimer.h"
#endif #endif
#if HAVE_STDLIB_H #ifdef HAVE_CTYPE_H
#include <stdlib.h> #include <ctype.h>
#endif
#ifdef HAVE_STRING_H
#include <string.h>
#endif #endif
extern struct RTS_FLAGS RtsFlags; extern struct RTS_FLAGS RtsFlags;
...@@ -238,12 +234,6 @@ void initRtsFlagsDefaults(void) ...@@ -238,12 +234,6 @@ void initRtsFlagsDefaults(void)
#ifdef PROFILING #ifdef PROFILING
RtsFlags.ProfFlags.doHeapProfile = rtsFalse; RtsFlags.ProfFlags.doHeapProfile = rtsFalse;
RtsFlags.ProfFlags.showCCSOnException = rtsFalse; RtsFlags.ProfFlags.showCCSOnException = rtsFalse;
RtsFlags.ProfFlags.ccSelector = NULL;
RtsFlags.ProfFlags.modSelector = NULL;
RtsFlags.ProfFlags.descrSelector = NULL;
RtsFlags.ProfFlags.typeSelector = NULL;
RtsFlags.ProfFlags.kindSelector = NULL;
#elif defined(DEBUG) #elif defined(DEBUG)
RtsFlags.ProfFlags.doHeapProfile = rtsFalse; RtsFlags.ProfFlags.doHeapProfile = rtsFalse;
#endif #endif
......
/* ----------------------------------------------------------------------------- /* -----------------------------------------------------------------------------
* $Id: RtsFlags.h,v 1.24 2000/04/03 15:54:50 simonmar Exp $ * $Id: RtsFlags.h,v 1.25 2000/04/19 12:42:48 simonmar Exp $
* *
* (c) The GHC Team, 1998-1999 * (c) The GHC Team, 1998-1999
* *
...@@ -100,12 +100,6 @@ struct PROFILING_FLAGS { ...@@ -100,12 +100,6 @@ struct PROFILING_FLAGS {
# define DESCRchar 'D' # define DESCRchar 'D'
# define TYPEchar 'Y' # define TYPEchar 'Y'
# define TIMEchar 'T' # define TIMEchar 'T'
char *ccSelector;
char *modSelector;
char *descrSelector;
char *typeSelector;
char *kindSelector;
}; };
#elif defined(DEBUG) #elif defined(DEBUG)
# define NO_HEAP_PROFILING 0 # define NO_HEAP_PROFILING 0
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment