Commit 066dbe78 authored by simonmar's avatar simonmar

[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
*
......@@ -32,8 +32,6 @@ static void clear_table_data(void);
static void fprint_data(FILE *fp);
#endif
char prof_filename[128]; /* urk */
/* -----------------------------------------------------------------------------
* Hash tables.
*
......@@ -148,7 +146,7 @@ reportCtrResid(FILE *fp)
/* -------------------------------------------------------------------------- */
#ifdef DEBUG_HEAP_PROF
FILE *prof_file;
FILE *hp_file;
void initProfiling1( void )
{
......@@ -172,14 +170,14 @@ initHeapProfiling(void)
return 0;
}
fprintf(prof_file, "JOB \"%s\"\n", prog_argv[0]);
fprintf(prof_file, "DATE \"%s\"\n", time_str());
fprintf(hp_file, "JOB \"%s\"\n", prog_argv[0]);
fprintf(hp_file, "DATE \"%s\"\n", time_str());
fprintf(prof_file, "SAMPLE_UNIT \"seconds\"\n");
fprintf(prof_file, "VALUE_UNIT \"bytes\"\n");
fprintf(hp_file, "SAMPLE_UNIT \"seconds\"\n");
fprintf(hp_file, "VALUE_UNIT \"bytes\"\n");
fprintf(prof_file, "BEGIN_SAMPLE 0.00\n");
fprintf(prof_file, "END_SAMPLE 0.00\n");
fprintf(hp_file, "BEGIN_SAMPLE 0.00\n");
fprintf(hp_file, "END_SAMPLE 0.00\n");
#ifdef DEBUG_HEAP_PROF
DEBUG_LoadSymbols(prog_argv[0]);
......@@ -203,9 +201,9 @@ endHeapProfiling(void)
}
seconds = mut_user_time();
fprintf(prof_file, "BEGIN_SAMPLE %0.2f\n", seconds);
fprintf(prof_file, "END_SAMPLE %0.2f\n", seconds);
fclose(prof_file);
fprintf(hp_file, "BEGIN_SAMPLE %0.2f\n", seconds);
fprintf(hp_file, "END_SAMPLE %0.2f\n", seconds);
fclose(hp_file);
}
#ifdef DEBUG_HEAP_PROF
......@@ -483,7 +481,7 @@ heapCensus(void)
bd = g0s0->to_space;
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) {
p = bd->start;
......@@ -602,10 +600,10 @@ heapCensus(void)
#ifdef DEBUG_HEAP_PROF
switch (RtsFlags.ProfFlags.doHeapProfile) {
case HEAP_BY_INFOPTR:
fprint_data(prof_file);
fprint_data(hp_file);
break;
case HEAP_BY_CLOSURE_TYPE:
fprint_closure_types(prof_file);
fprint_closure_types(hp_file);
break;
}
#endif
......@@ -613,19 +611,19 @@ heapCensus(void)
#ifdef PROFILING
switch (RtsFlags.ProfFlags.doHeapProfile) {
case HEAP_BY_CCS:
reportCCSResid(prof_file,CCS_MAIN);
reportCCSResid(hp_file,CCS_MAIN);
break;
case HEAP_BY_MOD:
case HEAP_BY_DESCR:
case HEAP_BY_TYPE:
reportCtrResid(prof_file);
reportCtrResid(hp_file);
break;
default:
barf("heapCensus; doHeapProfile");
}
#endif
fprintf(prof_file, "END_SAMPLE %0.2f\n", time);
fprintf(hp_file, "END_SAMPLE %0.2f\n", time);
}
#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
*
......@@ -46,11 +46,14 @@ rtsBool time_profiling = rtsFalse;
*/
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 */
FILE *prof_file;
static char *hp_filename; /* heap profile (hp2ps style) log file */
FILE *hp_file;
/* The Current Cost Centre Stack (for attributing costs)
*/
CostCentreStack *CCCS;
......@@ -149,7 +152,7 @@ initProfiling1 (void)
{
/* for the benefit of allocate()... */
CCCS = CCS_SYSTEM;
/* Initialize counters for IDs */
CC_ID = 1;
CCS_ID = 1;
......@@ -219,31 +222,45 @@ initProfiling2 (void)
static void
initProfilingLogFile(void)
{
/* Initialise the log file name */
prof_filename = stgMallocBytes(strlen(prog_argv[0]) + 6, "initProfiling");
sprintf(prof_filename, "%s.prof", prog_argv[0]);
/* open the log file */
if ((prof_file = fopen(prof_filename, "w")) == NULL) {
fprintf(stderr, "Can't open profiling report file %s\n", prof_filename);
RtsFlags.CcFlags.doCostCentres = 0;
return;
}
/* Initialise the log file name */
prof_filename = stgMallocBytes(strlen(prog_argv[0]) + 6, "initProfiling");
sprintf(prof_filename, "%s.prof", prog_argv[0]);
/* open the log file */
if ((prof_file = fopen(prof_filename, "w")) == NULL) {
fprintf(stderr, "Can't open profiling report file %s\n", prof_filename);
RtsFlags.CcFlags.doCostCentres = 0;
return;
}
if (RtsFlags.CcFlags.doCostCentres == COST_CENTRES_XML) {
/* dump the time, and the profiling interval */
fprintf(prof_file, "\"%s\"\n", time_str());
fprintf(prof_file, "\"%d ms\"\n", TICK_MILLISECS);
if (RtsFlags.CcFlags.doCostCentres == COST_CENTRES_XML) {
/* dump the time, and the profiling interval */
fprintf(prof_file, "\"%s\"\n", time_str());
fprintf(prof_file, "\"%d ms\"\n", TICK_MILLISECS);
/* declare all the cost centres */
{
CostCentre *cc;
for (cc = CC_LIST; cc != NULL; cc = cc->link) {
fprintf(prof_file, "%d %d \"%s\" \"%s\"\n",
CC_UQ, cc->ccID, cc->label, cc->module);
}
}
}
/* declare all the cost centres */
{
CostCentre *cc;
for (cc = CC_LIST; cc != NULL; cc = cc->link) {
fprintf(prof_file, "%d %d \"%s\" \"%s\"\n",
CC_UQ, cc->ccID, cc->label, cc->module);
}
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
......
/* -----------------------------------------------------------------------------
* $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
*
......@@ -13,6 +13,7 @@ void initProfiling2 ( void );
void endProfiling ( void );
extern FILE *prof_file;
extern FILE *hp_file;
#endif
#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 GHC Team, 1998-1999
......@@ -31,12 +31,8 @@
#include "Itimer.h"
#endif
#if HAVE_STDLIB_H
#include <stdlib.h>
#endif
#ifdef HAVE_STRING_H
#include <string.h>
#ifdef HAVE_CTYPE_H
#include <ctype.h>
#endif
extern struct RTS_FLAGS RtsFlags;
......@@ -238,12 +234,6 @@ void initRtsFlagsDefaults(void)
#ifdef PROFILING
RtsFlags.ProfFlags.doHeapProfile = 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)
RtsFlags.ProfFlags.doHeapProfile = rtsFalse;
#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
*
......@@ -100,12 +100,6 @@ struct PROFILING_FLAGS {
# define DESCRchar 'D'
# define TYPEchar 'Y'
# define TIMEchar 'T'
char *ccSelector;
char *modSelector;
char *descrSelector;
char *typeSelector;
char *kindSelector;
};
#elif defined(DEBUG)
# 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