Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
What's new
10
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in / Register
Toggle navigation
Open sidebar
Glasgow Haskell Compiler
GHC
Commits
a88d6139
Commit
a88d6139
authored
Feb 23, 1999
by
simonm
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
[project @ 1999-02-23 12:02:57 by simonm]
Print time spent collecting each generation.
parent
b8886039
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
32 additions
and
20 deletions
+32
-20
ghc/rts/Stats.c
ghc/rts/Stats.c
+32
-20
No files found.
ghc/rts/Stats.c
View file @
a88d6139
/* -----------------------------------------------------------------------------
* $Id: Stats.c,v 1.
7
1999/02/
09
12:
49:23
simonm Exp $
* $Id: Stats.c,v 1.
8
1999/02/
23
12:
02:57
simonm Exp $
*
* (c) The GHC Team, 1998-1999
*
...
...
@@ -78,27 +78,29 @@
/* huh? */
#define BIG_STRING_LEN 512
static
StgD
ouble
ElapsedTimeStart
=
0
.
0
;
static
StgD
ouble
TicksPerSecond
=
0
.
0
;
static
d
ouble
ElapsedTimeStart
=
0
.
0
;
static
d
ouble
TicksPerSecond
=
0
.
0
;
static
StgD
ouble
InitUserTime
=
0
.
0
;
static
StgD
ouble
InitElapsedTime
=
0
.
0
;
static
d
ouble
InitUserTime
=
0
.
0
;
static
d
ouble
InitElapsedTime
=
0
.
0
;
static
ullong
GC_tot_alloc
=
0
;
static
StgD
ouble
GC_start_time
,
GC_tot_time
=
0
;
/* User GC Time */
static
StgD
ouble
GCe_start_time
,
GCe_tot_time
=
0
;
/* Elapsed GC time */
static
d
ouble
GC_start_time
,
GC_tot_time
=
0
;
/* User GC Time */
static
d
ouble
GCe_start_time
,
GCe_tot_time
=
0
;
/* Elapsed GC time */
lnat
MaxResidency
=
0
;
/* in words; for stats only */
lnat
ResidencySamples
=
0
;
/* for stats only */
static
lnat
GC_start_faults
=
0
,
GC_end_faults
=
0
;
static
double
*
GC_coll_times
;
/* ToDo: convert this to use integers? --SDM */
/* elapsedtime() -- The current elapsed time in seconds */
StgD
ouble
d
ouble
elapsedtime
(
void
)
{
#if ! (defined(HAVE_TIMES) || defined(HAVE_FTIME))
...
...
@@ -118,7 +120,7 @@ elapsedtime(void)
struct
tms
t
;
clock_t
r
=
times
(
&
t
);
return
(((
StgD
ouble
)
r
)
/
TicksPerSecond
-
ElapsedTimeStart
);
return
(((
d
ouble
)
r
)
/
TicksPerSecond
-
ElapsedTimeStart
);
# else
/* HAVE_FTIME */
struct
timeb
t
;
...
...
@@ -156,11 +158,11 @@ start_time(void)
fprintf
(
stderr
,
"stat_init: bad call to 'sysconf'!
\n
"
);
stg_exit
(
EXIT_FAILURE
);
}
TicksPerSecond
=
(
StgD
ouble
)
ticks
;
TicksPerSecond
=
(
d
ouble
)
ticks
;
#else
/* no "sysconf"; had better guess */
# ifdef HZ
TicksPerSecond
=
(
StgD
ouble
)
(
HZ
);
TicksPerSecond
=
(
d
ouble
)
(
HZ
);
# else
/* had better guess wildly */
/* We will #ifdef around the fprintf for machines
...
...
@@ -178,16 +180,24 @@ start_time(void)
void
initStats
(
void
)
{
nat
i
;
FILE
*
sf
=
RtsFlags
.
GcFlags
.
statsFile
;
if
(
RtsFlags
.
GcFlags
.
giveStats
)
{
fprintf
(
sf
,
" Alloc Collect Live GC GC TOT TOT Page Flts
\n
"
);
fprintf
(
sf
,
" bytes bytes bytes user elap user elap
\n
"
);
}
GC_coll_times
=
(
double
*
)
stgMallocBytes
(
sizeof
(
double
)
*
RtsFlags
.
GcFlags
.
generations
,
"initStats"
);
for
(
i
=
0
;
i
<
RtsFlags
.
GcFlags
.
generations
;
i
++
)
{
GC_coll_times
[
i
]
=
0
.
0
;
}
}
StgD
ouble
d
ouble
usertime
(
void
)
{
#if ! (defined(HAVE_GETRUSAGE) || defined(HAVE_TIMES))
...
...
@@ -203,7 +213,7 @@ usertime(void)
struct
tms
t
;
times
(
&
t
);
return
(((
StgD
ouble
)(
t
.
tms_utime
))
/
TicksPerSecond
);
return
(((
d
ouble
)(
t
.
tms_utime
))
/
TicksPerSecond
);
#else
/* HAVE_GETRUSAGE */
struct
rusage
t
;
...
...
@@ -266,8 +276,8 @@ stat_endGC(lnat alloc, lnat collect, lnat live, lnat gen)
FILE
*
sf
=
RtsFlags
.
GcFlags
.
statsFile
;
if
(
sf
!=
NULL
)
{
StgD
ouble
time
=
usertime
();
StgD
ouble
etime
=
elapsedtime
();
d
ouble
time
=
usertime
();
d
ouble
etime
=
elapsedtime
();
if
(
RtsFlags
.
GcFlags
.
giveStats
)
{
nat
faults
=
pagefaults
();
...
...
@@ -287,6 +297,8 @@ stat_endGC(lnat alloc, lnat collect, lnat live, lnat gen)
fflush
(
sf
);
}
GC_coll_times
[
gen
]
+=
time
-
GC_start_time
;
GC_tot_alloc
+=
(
ullong
)
alloc
;
GC_tot_time
+=
time
-
GC_start_time
;
GCe_tot_time
+=
etime
-
GCe_start_time
;
...
...
@@ -320,9 +332,9 @@ stat_exit(int alloc)
if
(
sf
!=
NULL
){
char
temp
[
BIG_STRING_LEN
];
StgD
ouble
time
=
usertime
();
StgD
ouble
etime
=
elapsedtime
();
StgD
ouble
MutTime
,
MutElapsedTime
;
d
ouble
time
=
usertime
();
d
ouble
etime
=
elapsedtime
();
d
ouble
MutTime
,
MutElapsedTime
;
/* avoid divide by zero if time is measured as 0.00 seconds -- SDM */
if
(
time
==
0
.
0
)
time
=
0
.
0001
;
...
...
@@ -349,8 +361,8 @@ stat_exit(int alloc)
{
/* Count garbage collections */
nat
g
;
for
(
g
=
0
;
g
<
RtsFlags
.
GcFlags
.
generations
;
g
++
)
{
fprintf
(
sf
,
"%11d collections in generation %d
\n
"
,
generations
[
g
].
collections
,
g
);
fprintf
(
sf
,
"%11d collections in generation %d
(%6.2fs)
\n
"
,
generations
[
g
].
collections
,
g
,
GC_coll_times
[
g
]
);
}
}
fprintf
(
sf
,
"
\n
%11ld Mb total memory in use
\n\n
"
,
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment