rts: drop unused getThreadCPUTime
authorSergei Trofimovich <siarheit@google.com>
Sun, 7 Feb 2016 16:59:03 +0000 (16:59 +0000)
committerSergei Trofimovich <siarheit@google.com>
Sun, 7 Feb 2016 20:27:03 +0000 (20:27 +0000)
Use of this helper function was removed in:

    commit 3c9fc104337a142fe4f375d30d7a6b81d55a70c1
    Author: Brian Brooks <brooks.brian@gmail.com>
    Date:   Thu Jul 10 02:55:33 2014 -0500

        Avoid unnecessary clock_gettime() syscalls in GC stats.

Noticed by uselex.rb:
    getThreadCPUTime: [R]: exported from:
        ./rts/dist/build/posix/GetTime.p_o

Signed-off-by: Sergei Trofimovich <siarheit@google.com>
rts/GetTime.h
rts/posix/GetTime.c
rts/win32/GetTime.c

index 32c3754..4aaddd0 100644 (file)
@@ -14,7 +14,6 @@
 void initializeTimer       (void);
 
 Time getProcessCPUTime     (void);
-Time getThreadCPUTime      (void);
 Time getProcessElapsedTime (void);
 void getProcessTimes       (Time *user, Time *elapsed);
 
index def78a4..24d0d50 100644 (file)
@@ -171,36 +171,6 @@ void getProcessTimes(Time *user, Time *elapsed)
 
 #endif // HAVE_TIMES
 
-Time getThreadCPUTime(void)
-{
-#if !defined(BE_CONSERVATIVE)            &&  \
-     defined(HAVE_CLOCK_GETTIME)       &&  \
-     defined(_SC_CPUTIME)             &&  \
-     defined(CLOCK_PROCESS_CPUTIME_ID) &&  \
-     defined(HAVE_SYSCONF)
-    {
-        static int checked_sysconf = 0;
-        static int sysconf_result = 0;
-
-        if (!checked_sysconf) {
-            sysconf_result = sysconf(_SC_THREAD_CPUTIME);
-            checked_sysconf = 1;
-        }
-        if (sysconf_result != -1) {
-            // clock_gettime() gives us per-thread CPU time.  It isn't
-            // reliable on Linux, but it's the best we have.
-            struct timespec ts;
-            int res;
-            res = clock_gettime(CLOCK_THREAD_CPUTIME_ID, &ts);
-            if (res == 0) {
-                return SecondsToTime(ts.tv_sec) + NSToTime(ts.tv_nsec);
-            }
-        }
-    }
-#endif
-    return getProcessCPUTime();
-}
-
 void getUnixEpochTime(StgWord64 *sec, StgWord32 *nsec)
 {
 #if defined(HAVE_GETTIMEOFDAY)
index 3600839..6a45248 100644 (file)
@@ -100,19 +100,6 @@ getProcessElapsedTime(void)
     return NSToTime(getMonotonicNSec());
 }
 
-Time
-getThreadCPUTime(void)
-{
-    FILETIME creationTime, exitTime, userTime, kernelTime = {0,0};
-
-    if (!GetThreadTimes(GetCurrentThread(), &creationTime,
-                        &exitTime, &kernelTime, &userTime)) {
-        return 0;
-    }
-
-    return fileTimeToRtsTime(userTime);
-}
-
 void
 getUnixEpochTime(StgWord64 *sec, StgWord32 *nsec)
 {