Revision: 77862
          http://sourceforge.net/p/brlcad/code/77862
Author:   starseeker
Date:     2020-12-02 02:52:23 +0000 (Wed, 02 Dec 2020)
Log Message:
-----------
Make a stab at a portable librt timer.

This code attempts to replace the various librt timer* files with a
single implementation in C++.  Insofar as we can, use standard C/C++
functions to retrieve values.

Windows presents a complication in that clock() does not return CPU
time.  Per their documentation and examples, try to use the only
available option on that platform to get CPU time.

For elapsed time (I think this is intended to be wall clock time?)
use C++11 chrono support which should be portable across all targeted
platforms.

This needs review - I'm not sure we were returning CPU time from the
rt_get_timer function even on systems with a standards compliant
clock() available previously, so this may be a behavior change even
though it is trying to match the behavior described in rt/timer.h.

Modified Paths:
--------------
    brlcad/trunk/include/rt/timer.h
    brlcad/trunk/src/librt/CMakeLists.txt

Added Paths:
-----------
    brlcad/trunk/src/librt/timer.cpp

Removed Paths:
-------------
    brlcad/trunk/src/librt/timer-nt.c
    brlcad/trunk/src/librt/timer42.c
    brlcad/trunk/src/librt/timerunix.c

Modified: brlcad/trunk/include/rt/timer.h
===================================================================
--- brlcad/trunk/include/rt/timer.h     2020-12-02 01:52:48 UTC (rev 77861)
+++ brlcad/trunk/include/rt/timer.h     2020-12-02 02:52:23 UTC (rev 77862)
@@ -33,42 +33,24 @@
 /** @addtogroup rt_timer */
 /** @{ */
 /**
- * To provide timing information for RT.
- * THIS VERSION FOR Denelcor HEP/UPX (System III-like)
+ * Provide timing information for RT.
  */
 
 /**
- *
- * To provide timing information for RT when running on 4.2 BSD UNIX.
- *
+ * Initialize global librt timer
  */
+RT_EXPORT extern void rt_prep_timer(void);
 
 /**
- *
- * To provide timing information on Microsoft Windows NT.
+ * Reports on the passage of time, since rt_prep_timer() was called.  Explicit
+ * return is number of CPU seconds.  String return is descriptive.  If "wall"
+ * pointer is non-null, number of elapsed seconds per the wall clock are
+ * returned.  Times returned will never be zero.
  */
-/**
- *
- * To provide timing information for RT.  This version for any non-BSD
- * UNIX system, including System III, Vr1, Vr2.  Version 6 & 7 should
- * also be able to use this (untested).  The time() and times()
- * sys-calls are used for all timing.
- *
- */
+RT_EXPORT extern double rt_get_timer(struct bu_vls *vp, double *elapsed);
+/* Return CPU time, text, & wall clock time off the global timer */
 
-
-RT_EXPORT extern void rt_prep_timer(void);
-/* Read global timer, return time + str */
 /**
- * Reports on the passage of time, since rt_prep_timer() was called.
- * Explicit return is number of CPU seconds.  String return is
- * descriptive.  If "elapsed" pointer is non-null, number of elapsed
- * seconds are returned.  Times returned will never be zero.
- */
-RT_EXPORT extern double rt_get_timer(struct bu_vls *vp,
-                                    double *elapsed);
-/* Return CPU time, text, & wall clock time off the global timer */
-/**
  * Compatibility routine
  */
 RT_EXPORT extern double rt_read_timer(char *str, int len);

Modified: brlcad/trunk/src/librt/CMakeLists.txt
===================================================================
--- brlcad/trunk/src/librt/CMakeLists.txt       2020-12-02 01:52:48 UTC (rev 
77861)
+++ brlcad/trunk/src/librt/CMakeLists.txt       2020-12-02 02:52:23 UTC (rev 
77862)
@@ -216,6 +216,7 @@
   roots.c
   search.c
   shoot.c
+  timer.cpp
   tol.c
   transform.c
   tree.c
@@ -301,9 +302,6 @@
   test_dbio.c
   test_nurbsfit.cpp
   test_root3-subd.cpp
-  timer-nt.c
-  timer42.c
-  timerunix.c
   uvpoints.cpp
   )
 if(NOT BRLCAD_ENABLE_GCT)
@@ -350,12 +348,6 @@
 BRLCAD_ADDDATA(raydebug.tcl sample_applications)
 BRLCAD_ADDDATA(CL_FILES opencl)
 
-if(MSVC)
-  set(LIBRT_SOURCES ${LIBRT_SOURCES} timer-nt.c)
-else(MSVC)
-  set(LIBRT_SOURCES ${LIBRT_SOURCES} timer42.c)
-endif(MSVC)
-
 if(BRLCAD_ENABLE_OPENCL)
   set(OPENCL_LIBS ${OPENCL_LIBRARIES})
 endif(BRLCAD_ENABLE_OPENCL)

Deleted: brlcad/trunk/src/librt/timer-nt.c
===================================================================
--- brlcad/trunk/src/librt/timer-nt.c   2020-12-02 01:52:48 UTC (rev 77861)
+++ brlcad/trunk/src/librt/timer-nt.c   2020-12-02 02:52:23 UTC (rev 77862)
@@ -1,107 +0,0 @@
-/*                      T I M E R - N T . C
- * BRL-CAD
- *
- * Copyright (c) 2004-2020 United States Government as represented by
- * the U.S. Army Research Laboratory.
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public License
- * version 2.1 as published by the Free Software Foundation.
- *
- * This library is distributed in the hope that it will be useful, but
- * WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this file; see the file named COPYING for more
- * information.
- */
-
-#include "common.h"
-
-#include <string.h>
-#include <time.h>
-#include "bio.h"
-
-#include "vmath.h"
-#include "raytrace.h"
-
-/* Standard System V stuff */
-static clock_t start;
-time_t time0;
-
-
-void
-rt_prep_timer(void)
-{
-    start = clock();
-    time(&time0);
-}
-
-
-double
-rt_get_timer(struct bu_vls *vp, double *elapsed)
-{
-    time_t now;
-    double user_cpu_secs;
-    double sys_cpu_secs;
-    double elapsed_secs;
-    double percent;
-    clock_t finish;
-
-    /* Real time.  1 second resolution. */
-    (void)time(&now);
-    elapsed_secs = difftime(now, time0);
-
-    finish = clock();
-    sys_cpu_secs = (double)(finish - start);
-    sys_cpu_secs /= CLOCKS_PER_SEC;
-
-    user_cpu_secs = sys_cpu_secs;
-
-    if (user_cpu_secs < 0.00001) user_cpu_secs = 0.00001;
-    if (elapsed_secs < 0.00001) elapsed_secs = user_cpu_secs;  /* It can't be 
any less! */
-
-    if (elapsed)  *elapsed = elapsed_secs;
-
-    if (vp) {
-       percent = user_cpu_secs/elapsed_secs*100.0;
-       BU_CK_VLS(vp);
-       bu_vls_printf(vp,
-                     "%g user + %g sys in %g elapsed secs (%g%%)",
-                     user_cpu_secs, sys_cpu_secs, elapsed_secs, percent);
-    }
-    return user_cpu_secs;
-}
-
-
-double
-rt_read_timer(char *str, int len)
-{
-    struct bu_vls vls = BU_VLS_INIT_ZERO;
-    double cpu;
-    int todo;
-
-    if (!str)
-       return rt_get_timer((struct bu_vls *)0, (double *)0);
-
-    cpu = rt_get_timer(&vls, (double *)0);
-    todo = bu_vls_strlen(&vls);
-    if (todo > len)
-       todo = len;
-    bu_strlcpy(str, bu_vls_addr(&vls), todo);
-
-    return cpu;
-}
-
-
-/*
- * Local Variables:
- * mode: C
- * tab-width: 8
- * indent-tabs-mode: t
- * c-file-style: "stroustrup"
- * End:
- * ex: shiftwidth=4 tabstop=8
- */

Added: brlcad/trunk/src/librt/timer.cpp
===================================================================
--- brlcad/trunk/src/librt/timer.cpp                            (rev 0)
+++ brlcad/trunk/src/librt/timer.cpp    2020-12-02 02:52:23 UTC (rev 77862)
@@ -0,0 +1,124 @@
+/*                        T I M E R . C P P
+ * BRL-CAD
+ *
+ * Copyright (c) 1985-2020 United States Government as represented by
+ * the U.S. Army Research Laboratory.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public License
+ * version 2.1 as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful, but
+ * WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this file; see the file named COPYING for more
+ * information.
+ */
+
+#include "common.h"
+#include "bio.h"
+#include <ctime>
+#include <chrono>
+#include <sstream>
+#include <iomanip>
+#include "bu/str.h"
+#include "bu/vls.h"
+#include "rt/timer.h"
+
+#ifdef HAVE_GETPROCESSTIMES
+static double  time_cpu;       /* Time at which timing started */
+#else
+static clock_t time_cpu;       /* Time at which timing started */
+#endif
+static std::chrono::steady_clock::time_point time_wall;
+
+void
+rt_prep_timer(void)
+{
+#ifdef HAVE_GETPROCESSTIMES
+    FILETIME a,b,c,d;
+    time_cpu = 0.0;
+    if (!GetProcessTimes(GetCurrentProcess(),&a,&b,&c,&d)) {
+       bu_log("Warning - could not initialize RT timer!\n");
+       return;
+    }
+    /* https://stackoverflow.com/a/17440673 */
+    time_cpu = (double)(d.dwLowDateTime | ((unsigned long 
long)d.dwHighDateTime << 32)) * 0.0000001;
+#else
+    time_cpu = clock();
+#endif
+    time_wall = std::chrono::steady_clock::now();
+}
+
+double
+rt_get_timer(struct bu_vls *vp, double *elapsed)
+{
+
+    double user_cpu_secs;
+    double elapsed_secs;
+
+#ifdef HAVE_GETPROCESSTIMES
+    FILETIME a,b,c,d;
+    double time1 = DBL_MAX;
+    if (!GetProcessTimes(GetCurrentProcess(),&a,&b,&c,&d)) {
+       bu_log("Warning - could not initialize RT timer!\n");
+       return;
+    }
+    /* https://stackoverflow.com/a/17440673 */
+    time1 = (double)(d.dwLowDateTime | ((unsigned long long)d.dwHighDateTime 
<< 32)) * 0.0000001;
+    user_cpu_secs = time1 - time0;
+#else
+    clock_t time1 = clock();
+    user_cpu_secs = (double)(time1 - time_cpu)/CLOCKS_PER_SEC;
+#endif
+
+    std::chrono::steady_clock::time_point wall_now = 
std::chrono::steady_clock::now();
+    elapsed_secs = 
std::chrono::duration_cast<std::chrono::microseconds>(wall_now - 
time_wall).count();
+    elapsed_secs = elapsed_secs / 1e6;
+
+    if (elapsed)  *elapsed = elapsed_secs;
+
+    if (vp) {
+       std::stringstream ss;
+       ss << std::fixed << std::setprecision(5) << elapsed_secs;
+       std::string sstr = ss.str();
+       bu_vls_printf(vp, "cpu = %g sec, elapsed = %s sec\n", user_cpu_secs, 
sstr.c_str());
+    }
+
+    return user_cpu_secs;
+}
+
+double
+rt_read_timer(char *str, int len)
+{
+    struct bu_vls vls = BU_VLS_INIT_ZERO;
+    double cpu;
+    int todo;
+
+    if (!str)
+       return rt_get_timer((struct bu_vls *)0, (double *)0);
+
+    cpu = rt_get_timer(&vls, (double *)0);
+    todo = bu_vls_strlen(&vls);
+
+    /* Whatever the vls length is, we're not writing more
+     * content than the str length supplied by the caller */
+    todo = (todo > len) ? len : todo;
+
+    bu_strlcpy(str, bu_vls_addr(&vls), todo);
+
+    return cpu;
+}
+
+
+// Local Variables:
+// tab-width: 8
+// mode: C++
+// c-basic-offset: 4
+// indent-tabs-mode: t
+// c-file-style: "stroustrup"
+// End:
+// ex: shiftwidth=4 tabstop=8


Property changes on: brlcad/trunk/src/librt/timer.cpp
___________________________________________________________________
Added: svn:eol-style
## -0,0 +1 ##
+native
\ No newline at end of property
Added: svn:mime-type
## -0,0 +1 ##
+text/plain
\ No newline at end of property
Deleted: brlcad/trunk/src/librt/timer42.c
===================================================================
--- brlcad/trunk/src/librt/timer42.c    2020-12-02 01:52:48 UTC (rev 77861)
+++ brlcad/trunk/src/librt/timer42.c    2020-12-02 02:52:23 UTC (rev 77862)
@@ -1,249 +0,0 @@
-/*                       T I M E R 4 2 . C
- * BRL-CAD
- *
- * Copyright (c) 1985-2020 United States Government as represented by
- * the U.S. Army Research Laboratory.
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public License
- * version 2.1 as published by the Free Software Foundation.
- *
- * This library is distributed in the hope that it will be useful, but
- * WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this file; see the file named COPYING for more
- * information.
- */
-
-#include "common.h"
-
-#include <stdio.h>
-#include <string.h>
-#include <sys/types.h>
-
-#include "bresource.h"
-
-#include "vmath.h"
-#include "raytrace.h"
-
-#ifndef HAVE_DECL_GETTIMEOFDAY
-extern int gettimeofday(struct timeval *, void *);
-#endif
-
-
-static struct timeval time0;   /* Time at which timing started */
-static struct rusage ru0;      /* Resource utilization at the start */
-static struct rusage ru0c;     /* Resource utilization at the start */
-
-static void prusage(register struct rusage *r0, register struct rusage *r1, 
struct timeval *e, struct timeval *b, struct bu_vls *vp);
-static void tvsub(struct timeval *tdiff, struct timeval *t1, struct timeval 
*t0);
-static void psecs(long int l, struct bu_vls *vp);
-
-
-void
-rt_prep_timer(void)
-{
-    gettimeofday(&time0, (struct timezone *)0);
-    getrusage(RUSAGE_SELF, &ru0);
-    getrusage(RUSAGE_CHILDREN, &ru0c);
-}
-
-
-double
-rt_get_timer(struct bu_vls *vp, double *elapsed)
-{
-    struct timeval timedol;
-    struct rusage ru1;
-    struct rusage ru1c;
-    struct timeval td;
-    double user_cpu_secs;
-    double elapsed_secs;
-
-
-    getrusage(RUSAGE_SELF, &ru1);
-    getrusage(RUSAGE_CHILDREN, &ru1c);
-    gettimeofday(&timedol, (struct timezone *)0);
-
-    elapsed_secs = (timedol.tv_sec - time0.tv_sec) +
-       (timedol.tv_usec - time0.tv_usec)/1000000.0;
-
-    tvsub(&td, &ru1.ru_utime, &ru0.ru_utime);
-    user_cpu_secs = td.tv_sec + ((double)td.tv_usec) / 1000000.0;
-
-    tvsub(&td, &ru1c.ru_utime, &ru0c.ru_utime);
-    user_cpu_secs += td.tv_sec + ((double)td.tv_usec) / 1000000.0;
-
-    if (user_cpu_secs < 0.00001) user_cpu_secs = 0.00001;
-    if (elapsed_secs < 0.00001) elapsed_secs = user_cpu_secs;  /* It can't be 
any less! */
-
-    if (elapsed)  *elapsed = elapsed_secs;
-
-    if (vp) {
-       bu_vls_printf(vp, "cpu = %g sec, elapsed = %g sec\n",
-                     user_cpu_secs, elapsed_secs);
-       bu_vls_strcat(vp, "    parent: ");
-       prusage(&ru0, &ru1, &timedol, &time0, vp);
-       bu_vls_strcat(vp, "\n  children: ");
-       prusage(&ru0c, &ru1c, &timedol, &time0, vp);
-    }
-
-    return user_cpu_secs;
-}
-
-
-static void
-prusage(register struct rusage *r0, register struct rusage *r1, struct timeval 
*e, struct timeval *b, struct bu_vls *vp)
-{
-    struct timeval tdiff;
-    time_t t;
-    char *cp;
-    int ms;
-
-    BU_CK_VLS(vp);
-
-    t = (r1->ru_utime.tv_sec-r0->ru_utime.tv_sec)*100+
-       (r1->ru_utime.tv_usec-r0->ru_utime.tv_usec)/10000+
-       (r1->ru_stime.tv_sec-r0->ru_stime.tv_sec)*100+
-       (r1->ru_stime.tv_usec-r0->ru_stime.tv_usec)/10000;
-    ms =  (e->tv_sec-b->tv_sec)*100 + (e->tv_usec-b->tv_usec)/10000;
-
-    cp = "%Uuser %Ssys %Ereal %P %Xi+%Dd %Mmaxrss %F+%Rpf %Ccsw";
-    for (; *cp; cp++) {
-       if (*cp != '%')
-           bu_vls_putc(vp, *cp);
-       else if (cp[1]) switch (*++cp) {
-               case 'E':
-                   psecs(ms / 100, vp);
-                   break;
-
-               case 'P':
-                   bu_vls_printf(vp, "%d%%", (int) (t*100 / ((ms ? ms : 1))));
-                   break;
-
-               case 'U':
-                   tvsub(&tdiff, &r1->ru_utime, &r0->ru_utime);
-                   bu_vls_printf(vp, "%ld.%01ld", (long)tdiff.tv_sec, 
(long)(tdiff.tv_usec/100000));
-                   break;
-
-               case 'S':
-                   tvsub(&tdiff, &r1->ru_stime, &r0->ru_stime);
-                   bu_vls_printf(vp, "%ld.%01ld", (long)tdiff.tv_sec, 
(long)(tdiff.tv_usec/100000));
-                   break;
-
-#ifndef _POSIX_C_SOURCE
-
-               case 'W':
-               {
-                   int i = r1->ru_nswap - r0->ru_nswap;
-                   bu_vls_printf(vp, "%d", i);
-                   break;
-               }
-
-               case 'X':
-                   bu_vls_printf(vp, "%ld", (long)(t == 0 ? 0 : 
(r1->ru_ixrss-r0->ru_ixrss)/t));
-                   break;
-
-               case 'D':
-                   bu_vls_printf(vp, "%ld", (long)(t == 0 ? 0 : 
(r1->ru_idrss+r1->ru_isrss-(r0->ru_idrss+r0->ru_isrss))/t));
-                   break;
-
-               case 'K':
-                   bu_vls_printf(vp, "%ld", (long)(t == 0 ? 0 :  
((r1->ru_ixrss+r1->ru_isrss+r1->ru_idrss) - 
(r0->ru_ixrss+r0->ru_idrss+r0->ru_isrss))/t));
-                   break;
-
-               case 'M':
-                   bu_vls_printf(vp, "%ld", (long)(r1->ru_maxrss/2));
-                   break;
-
-               case 'F':
-                   bu_vls_printf(vp, "%ld", 
(long)(r1->ru_majflt-r0->ru_majflt));
-                   break;
-
-               case 'R':
-                   bu_vls_printf(vp, "%ld", 
(long)(r1->ru_minflt-r0->ru_minflt));
-                   break;
-
-               case 'I':
-                   bu_vls_printf(vp, "%ld", 
(long)(r1->ru_inblock-r0->ru_inblock));
-                   break;
-
-               case 'O':
-                   bu_vls_printf(vp, "%ld", 
(long)(r1->ru_oublock-r0->ru_oublock));
-                   break;
-
-               case 'C':
-                   bu_vls_printf(vp, "%ld+%ld", 
(long)(r1->ru_nvcsw-r0->ru_nvcsw), (long)(r1->ru_nivcsw-r0->ru_nivcsw));
-                   break;
-
-#endif /* _POSIX_C_SOURCE */
-
-           }
-    }
-}
-
-
-static void
-tvsub(struct timeval *tdiff, struct timeval *t1, struct timeval *t0)
-{
-
-    tdiff->tv_sec = t1->tv_sec - t0->tv_sec;
-    tdiff->tv_usec = t1->tv_usec - t0->tv_usec;
-    if (tdiff->tv_usec < 0)
-       tdiff->tv_sec--, tdiff->tv_usec += 1000000;
-}
-
-
-static void
-psecs(long int l, struct bu_vls *vp)
-{
-    register int i;
-
-    i = l / 3600;
-    if (i) {
-       register int j;
-       bu_vls_printf(vp, "%d:", i);
-       i = l % 3600;
-       j = i / 60;
-       bu_vls_printf(vp, "%d%d", j / 10, j % 10);
-    } else {
-       i = l;
-       bu_vls_printf(vp, "%d", i / 60);
-    }
-    i = i % 60;
-    bu_vls_printf(vp, ":%d%d", i / 10, i % 10);
-}
-
-
-double
-rt_read_timer(char *str, int len)
-{
-    struct bu_vls vls = BU_VLS_INIT_ZERO;
-    double cpu;
-    int todo;
-
-    if (!str)
-       return rt_get_timer((struct bu_vls *)0, (double *)0);
-
-    cpu = rt_get_timer(&vls, (double *)0);
-    todo = bu_vls_strlen(&vls);
-
-    if (todo > len)
-       todo = len;
-    bu_strlcpy(str, bu_vls_addr(&vls), todo);
-
-    return cpu;
-}
-
-
-/*
- * Local Variables:
- * mode: C
- * tab-width: 8
- * indent-tabs-mode: t
- * c-file-style: "stroustrup"
- * End:
- * ex: shiftwidth=4 tabstop=8
- */

Deleted: brlcad/trunk/src/librt/timerunix.c
===================================================================
--- brlcad/trunk/src/librt/timerunix.c  2020-12-02 01:52:48 UTC (rev 77861)
+++ brlcad/trunk/src/librt/timerunix.c  2020-12-02 02:52:23 UTC (rev 77862)
@@ -1,136 +0,0 @@
-/*                     T I M E R U N I X . C
- * BRL-CAD
- *
- * Copyright (c) 1985-2020 United States Government as represented by
- * the U.S. Army Research Laboratory.
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public License
- * version 2.1 as published by the Free Software Foundation.
- *
- * This library is distributed in the hope that it will be useful, but
- * WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this file; see the file named COPYING for more
- * information.
- */
-
-
-#include "common.h"
-
-#include <stdio.h>
-#ifdef HAVE_MEMORY_H
-#include <memory.h>
-#endif
-#include <sys/types.h>
-#include <sys/times.h>
-#include <sys/param.h>
-
-#ifdef HAVE_SYS_MACHD_H
-# include <sys/machd.h>
-#endif
-
-#include "bu/vls.h"
-#include "bu/str.h"
-
-#ifndef HAVE_DECL_TIME
-time_t time(time_t *);
-#endif
-
-
-#ifndef HZ
-/* It's not always in sys/param.h;  if not, guess */
-#  define HZ 60
-#  define DEFAULT_HZ yes
-#endif
-
-
-/* Standard System V stuff */
-static time_t time0;
-static struct tms tms0;
-
-void
-rt_prep_timer(void)
-{
-    (void)time(&time0);
-    (void)times(&tms0);
-}
-
-
-double
-rt_get_timer(struct bu_vls *vp, double *elapsed)
-{
-    time_t now;
-    double user_cpu_secs;
-    double sys_cpu_secs;
-    double elapsed_secs;
-    double percent;
-    struct tms tmsnow;
-
-    /* Real time.  1 second resolution. */
-    (void)time(&now);
-    elapsed_secs = now-time0;
-
-    /* CPU time */
-    (void)times(&tmsnow);
-    user_cpu_secs = (tmsnow.tms_utime + tmsnow.tms_cutime) -
-       (tms0.tms_utime + tms0.tms_cutime);
-    user_cpu_secs /= HZ;
-    sys_cpu_secs = (tmsnow.tms_stime + tmsnow.tms_cstime) -
-       (tms0.tms_stime + tms0.tms_cstime);
-    sys_cpu_secs /= HZ;
-    if (user_cpu_secs < 0.00001) user_cpu_secs = 0.00001;
-    if (elapsed_secs < 0.00001) elapsed_secs = user_cpu_secs;  /* It can't be 
any less! */
-
-    if (elapsed)  *elapsed = elapsed_secs;
-
-    if (vp) {
-       percent = user_cpu_secs/elapsed_secs*100.0;
-       BU_CK_VLS(vp);
-#ifdef DEFAULT_HZ
-       bu_vls_printf(vp,
-                     "%g user + %g sys in %g elapsed secs (%g%%) WARNING: 
HZ=60 assumed, fix librt/timerunix.c",
-                     user_cpu_secs, sys_cpu_secs, elapsed_secs, percent);
-#else
-       bu_vls_printf(vp,
-                     "%g user + %g sys in %g elapsed secs (%g%%)",
-                     user_cpu_secs, sys_cpu_secs, elapsed_secs, percent);
-#endif
-    }
-    return user_cpu_secs;
-}
-
-
-double
-rt_read_timer(char *str, int len)
-{
-    struct bu_vls vls = BU_VLS_INIT_ZERO;
-    double cpu;
-    int todo;
-
-    if (!str)
-       return rt_get_timer((struct bu_vls *)0, (double *)0);
-
-    cpu = rt_get_timer(&vls, (double *)0);
-    todo = bu_vls_strlen(&vls);
-
-    if (todo > len)
-       todo = len;
-    bu_strlcpy(str, bu_vls_addr(&vls), todo);
-
-    return cpu;
-}
-
-
-/*
- * Local Variables:
- * mode: C
- * tab-width: 8
- * indent-tabs-mode: t
- * c-file-style: "stroustrup"
- * End:
- * ex: shiftwidth=4 tabstop=8
- */

This was sent by the SourceForge.net collaborative development platform, the 
world's largest Open Source development site.



_______________________________________________
BRL-CAD Source Commits mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/brlcad-commits

Reply via email to