Revision: 77866
http://sourceforge.net/p/brlcad/code/77866
Author: starseeker
Date: 2020-12-02 03:11:49 +0000 (Wed, 02 Dec 2020)
Log Message:
-----------
Merge from trunk - r77857 through r77865. These changes reduce the platform
symbol count back below the original trunk number to offset additions in the
new third party build logic.
Modified Paths:
--------------
brlcad/branches/extbuild/CMakeLists.txt
brlcad/branches/extbuild/include/rt/timer.h
brlcad/branches/extbuild/misc/CMake/BRLCAD_Environment_Setup.cmake
brlcad/branches/extbuild/misc/CMake/BRLCAD_Install_Prefix.cmake
brlcad/branches/extbuild/misc/CMake/BRLCAD_User_Options.cmake
brlcad/branches/extbuild/src/librt/CMakeLists.txt
Added Paths:
-----------
brlcad/branches/extbuild/src/librt/timer.cpp
Removed Paths:
-------------
brlcad/branches/extbuild/src/librt/timer-nt.c
brlcad/branches/extbuild/src/librt/timer42.c
brlcad/branches/extbuild/src/librt/timerunix.c
Property Changed:
----------------
brlcad/branches/extbuild/
brlcad/branches/extbuild/include/
Index: brlcad/branches/extbuild
===================================================================
--- brlcad/branches/extbuild 2020-12-02 03:02:54 UTC (rev 77865)
+++ brlcad/branches/extbuild 2020-12-02 03:11:49 UTC (rev 77866)
Property changes on: brlcad/branches/extbuild
___________________________________________________________________
Modified: svn:mergeinfo
## -11,4 +11,4 ##
/brlcad/branches/osg:62110-62113
/brlcad/branches/prep-cache:68236-68933
/brlcad/branches/tcltk86:68300-75257
-/brlcad/trunk:77547-77857
\ No newline at end of property
+/brlcad/trunk:77547-77865
\ No newline at end of property
Modified: brlcad/branches/extbuild/CMakeLists.txt
===================================================================
--- brlcad/branches/extbuild/CMakeLists.txt 2020-12-02 03:02:54 UTC (rev
77865)
+++ brlcad/branches/extbuild/CMakeLists.txt 2020-12-02 03:11:49 UTC (rev
77866)
@@ -1729,6 +1729,20 @@
CONFIG_H_APPEND(BRLCAD "#define HAVE_GETFULLPATHNAME 1\n")
endif(HAVE_GETFULLPATHNAME)
+# If we have GetProcessTimes, we need it instead of clock() for CPU time.
+# https://docs.microsoft.com/en-us/cpp/c-runtime-library/reference/clock
+check_c_source_compiles("
+#include <windows.h>
+int main() {
+FILETIME a,b,c,d;
+(void)GetProcessTimes(GetCurrentProcess(),&a,&b,&c,&d);
+return 0;
+}
+" HAVE_GETPROCESSTIMES)
+if(HAVE_GETPROCESSTIMES)
+ CONFIG_H_APPEND(BRLCAD "#define HAVE_GETPROCESSTIMES 1\n")
+endif(HAVE_GETPROCESSTIMES)
+
# GetCurrentProcessId
check_c_source_compiles("
#include <windows.h>
Index: brlcad/branches/extbuild/include
===================================================================
--- brlcad/branches/extbuild/include 2020-12-02 03:02:54 UTC (rev 77865)
+++ brlcad/branches/extbuild/include 2020-12-02 03:11:49 UTC (rev 77866)
Property changes on: brlcad/branches/extbuild/include
___________________________________________________________________
Modified: svn:mergeinfo
## -10,4 +10,4 ##
/brlcad/branches/osg/include:62110-62113
/brlcad/branches/prep-cache/include:68236-68933
/brlcad/branches/tcltk86/include:68300-75257
-/brlcad/trunk/include:77660-77699,77784-77829,77838-77857
\ No newline at end of property
+/brlcad/trunk/include:77660-77699,77784-77829,77838-77865
\ No newline at end of property
Modified: brlcad/branches/extbuild/include/rt/timer.h
===================================================================
--- brlcad/branches/extbuild/include/rt/timer.h 2020-12-02 03:02:54 UTC (rev
77865)
+++ brlcad/branches/extbuild/include/rt/timer.h 2020-12-02 03:11:49 UTC (rev
77866)
@@ -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/branches/extbuild/misc/CMake/BRLCAD_Environment_Setup.cmake
===================================================================
--- brlcad/branches/extbuild/misc/CMake/BRLCAD_Environment_Setup.cmake
2020-12-02 03:02:54 UTC (rev 77865)
+++ brlcad/branches/extbuild/misc/CMake/BRLCAD_Environment_Setup.cmake
2020-12-02 03:11:49 UTC (rev 77866)
@@ -91,12 +91,7 @@
message(WARNING "Valid options are AUTO, 32BIT and 64BIT")
set(BRLCAD_WORD_SIZE "AUTO" CACHE STRING WORD_SIZE_LABEL FORCE)
endif(NOT BRLCAD_WORD_SIZE MATCHES "AUTO" AND NOT BRLCAD_WORD_SIZE MATCHES
"64BIT" AND NOT BRLCAD_WORD_SIZE MATCHES "32BIT")
-# On Windows, we can't set word size at CMake configure time - the
-# compiler chosen at the beginning dictates the result. Mark as
-# advanced in that situation.
-if(MSVC)
- mark_as_advanced(BRLCAD_WORD_SIZE)
-endif(MSVC)
+mark_as_advanced(BRLCAD_WORD_SIZE)
# calculate the size of a pointer if we haven't already
include(CheckTypeSize)
@@ -155,11 +150,10 @@
endif(CMAKE_CL_64)
endif(MSVC)
-if (APPLE)
- if (${CMAKE_WORD_SIZE} MATCHES "32BIT")
- set(CMAKE_OSX_ARCHITECTURES "i386" CACHE STRING "Building for i386" FORCE)
- endif (${CMAKE_WORD_SIZE} MATCHES "32BIT")
-endif (APPLE)
+# If a platform specific variable needs to be set for 32 bit, do it here
+if (${CMAKE_WORD_SIZE} MATCHES "32BIT")
+ set(CMAKE_OSX_ARCHITECTURES "i386" CACHE STRING "Building for i386"
FORCE)
+endif (${CMAKE_WORD_SIZE} MATCHES "32BIT")
# Based on what we are doing, we may need to constrain our search paths
#
Modified: brlcad/branches/extbuild/misc/CMake/BRLCAD_Install_Prefix.cmake
===================================================================
--- brlcad/branches/extbuild/misc/CMake/BRLCAD_Install_Prefix.cmake
2020-12-02 03:02:54 UTC (rev 77865)
+++ brlcad/branches/extbuild/misc/CMake/BRLCAD_Install_Prefix.cmake
2020-12-02 03:11:49 UTC (rev 77866)
@@ -7,32 +7,7 @@
# CMAKE_INSTALL_PREFIX hasn't been set already, to try and allow
# parent builds (if any) some control.
-# TODO - generator expressions may be a way to replace some of this logic (or
-# improve it) by letting us ditch the logic tracking whether the path is
-# initialized to default - that's used to know whether or not it is safe to
-# override CMAKE_INSTALL_PREFIX based on build type. If we use the generator
-# expressions, we won't have to be concerned about that - problem is that
-# change will require updating all the install commands in the build target
-# functions. Third party logic will probably need to shift over to the new
-# ExternalProject_Add approach first as well - that way unmodified install
-# commands in 3rd party CMake files will be moot.
-#
-# if (NOT CMAKE_INSTALL_PREFIX)
-# set(CMAKE_INSTALL_PREFIX "/usr/brlcad/")
-# if (NOT MSVC)
-# set(gen_exp
$<IF:$<CONFIG:Debug>,dev-${BRLCAD_VERSION}/,$<IF:$<CONFIG:Release>,rel-${BRLCAD_VERSION}/${BRLCAD_VERSION},>>)
-# else (NOT MSVC)
-# set(gen_exp)
-# if(CMAKE_CL_64)
-# set(CMAKE_INSTALL_PREFIX "C:/Program Files/BRL-CAD
${BRLCAD_VERSION}")
-# else(CMAKE_CL_64)
-# set(CMAKE_INSTALL_PREFIX "C:/Program Files (x86)/BRL-CAD
${BRLCAD_VERSION}")
-# endif(CMAKE_CL_64)
-# endif (NOT MSVC)
-# endif (NOT CMAKE_INSTALL_PREFIX)
-# install(TARGETS mged DESTINATION ${gen_exp}${BIN_DIR})
-#
-# Another (maybe better) option instead of generators might be to use the
CONFIGURATIONS
+# TODO - explore use the CONFIGURATIONS
# option in our macros and the ExternalProject_Add management:
# https://cmake.org/cmake/help/latest/command/install.html
#
Modified: brlcad/branches/extbuild/misc/CMake/BRLCAD_User_Options.cmake
===================================================================
--- brlcad/branches/extbuild/misc/CMake/BRLCAD_User_Options.cmake
2020-12-02 03:02:54 UTC (rev 77865)
+++ brlcad/branches/extbuild/misc/CMake/BRLCAD_User_Options.cmake
2020-12-02 03:11:49 UTC (rev 77866)
@@ -390,9 +390,7 @@
#----------------------------------------------------------------------
# Some generators in CMake support generating folders in IDEs for
# organizing build targets. We want to use them if they are there.
-if(MSVC)
- set_property(GLOBAL PROPERTY USE_FOLDERS ON)
-endif(MSVC)
+set_property(GLOBAL PROPERTY USE_FOLDERS ON)
#----------------------------------------------------------------------
# There are extra documentation files available requiring DocBook
Modified: brlcad/branches/extbuild/src/librt/CMakeLists.txt
===================================================================
--- brlcad/branches/extbuild/src/librt/CMakeLists.txt 2020-12-02 03:02:54 UTC
(rev 77865)
+++ brlcad/branches/extbuild/src/librt/CMakeLists.txt 2020-12-02 03:11:49 UTC
(rev 77866)
@@ -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/branches/extbuild/src/librt/timer-nt.c
===================================================================
--- brlcad/branches/extbuild/src/librt/timer-nt.c 2020-12-02 03:02:54 UTC
(rev 77865)
+++ brlcad/branches/extbuild/src/librt/timer-nt.c 2020-12-02 03:11:49 UTC
(rev 77866)
@@ -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
- */
Copied: brlcad/branches/extbuild/src/librt/timer.cpp (from rev 77865,
brlcad/trunk/src/librt/timer.cpp)
===================================================================
--- brlcad/branches/extbuild/src/librt/timer.cpp
(rev 0)
+++ brlcad/branches/extbuild/src/librt/timer.cpp 2020-12-02 03:11:49 UTC
(rev 77866)
@@ -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
Deleted: brlcad/branches/extbuild/src/librt/timer42.c
===================================================================
--- brlcad/branches/extbuild/src/librt/timer42.c 2020-12-02 03:02:54 UTC
(rev 77865)
+++ brlcad/branches/extbuild/src/librt/timer42.c 2020-12-02 03:11:49 UTC
(rev 77866)
@@ -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/branches/extbuild/src/librt/timerunix.c
===================================================================
--- brlcad/branches/extbuild/src/librt/timerunix.c 2020-12-02 03:02:54 UTC
(rev 77865)
+++ brlcad/branches/extbuild/src/librt/timerunix.c 2020-12-02 03:11:49 UTC
(rev 77866)
@@ -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