summaryrefslogtreecommitdiff
path: root/ghc/rts/Task.c
diff options
context:
space:
mode:
authorsimonmar <unknown>2005-11-03 11:05:38 +0000
committersimonmar <unknown>2005-11-03 11:05:38 +0000
commitcc2926f3a6942e6c512bb64bfe2c2a6aae2c72b4 (patch)
tree8ed575dc70b29025fc4ecc61c7b77da0815382df /ghc/rts/Task.c
parent74df0d16d17647ab46344802ed57533d38727479 (diff)
downloadhaskell-cc2926f3a6942e6c512bb64bfe2c2a6aae2c72b4.tar.gz
[project @ 2005-11-03 11:05:38 by simonmar]
Improvments to time-measurement and stats: - move all the platform-dependent timing related stuff into posix/GetTime.c and win32/GetTime.c, with the machine-indepent interface specified in GetTime.h. This is now used by Stats.c. - On Unix, use gettimeofday() and getrusage() by default, falling back to time() if one of these isn't available. - try to implement thread-specfic CPU-time measurement using clock_gettime() on Unix. Doesn't work reliably on Linux, because the implemenation tries to use the processor TSC, which on an SMP machine goes wrong when the thread moves between CPUs. However, it's slightly less bogus that before, and hopefully will improve in the future.
Diffstat (limited to 'ghc/rts/Task.c')
-rw-r--r--ghc/rts/Task.c12
1 files changed, 8 insertions, 4 deletions
diff --git a/ghc/rts/Task.c b/ghc/rts/Task.c
index 683c665d1a..b8bf1c4c8b 100644
--- a/ghc/rts/Task.c
+++ b/ghc/rts/Task.c
@@ -77,7 +77,7 @@ static Task*
newTask (void)
{
#if defined(THREADED_RTS)
- long currentElapsedTime, currentUserTime, elapsedGCTime;
+ Ticks currentElapsedTime, currentUserTime;
#endif
Task *task;
@@ -97,7 +97,7 @@ newTask (void)
#endif
#if defined(THREADED_RTS)
- stat_getTimes(&currentElapsedTime, &currentUserTime, &elapsedGCTime);
+ getProcessTimes(&currentUserTime, &currentElapsedTime);
task->mut_time = 0.0;
task->mut_etime = 0.0;
task->gc_time = 0.0;
@@ -188,13 +188,17 @@ taskStop (Task *task)
{
#if defined(THREADED_RTS)
OSThreadId id;
- long currentElapsedTime, currentUserTime, elapsedGCTime;
+ Ticks currentElapsedTime, currentUserTime, elapsedGCTime;
id = osThreadId();
ASSERT(task->id == id);
ASSERT(myTask() == task);
- stat_getTimes(&currentElapsedTime, &currentUserTime, &elapsedGCTime);
+ getProcessTimes(&currentUserTime, &currentElapsedTime);
+
+ // XXX this is wrong; we want elapsed GC time since the
+ // Task started.
+ elapsedGCTime = stat_getElapsedGCTime();
task->mut_time =
currentUserTime - task->muttimestart - task->gc_time;