//=========================================================================== // GoTools Core - SINTEF Geometry Tools Core library, version 2.0.1 // // Copyright (C) 2000-2007, 2010 SINTEF ICT, Applied Mathematics, Norway. // // This program is free software; you can redistribute it and/or // modify it under the terms of the GNU General Public License // as published by the Free Software Foundation version 2 of the License. // // This program 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 General Public License for more details. // // You should have received a copy of the GNU General Public License // along with this program; if not, write to the Free Software // Foundation, Inc., // 59 Temple Place - Suite 330, // Boston, MA 02111-1307, USA. // // Contact information: E-mail: tor.dokken@sintef.no // SINTEF ICT, Department of Applied Mathematics, // P.O. Box 124 Blindern, // 0314 Oslo, Norway. // // Other licenses are also available for this software, notably licenses // for: // - Building commercial software. // - Building software whose source code you wish to keep private. //=========================================================================== 00014 #ifndef CPUCLOCK_H 00015 #define CPUCLOCK_H 00016 00017 #include <string> 00018 #include "GoTools/utils/timeutils.h" 00019 00020 namespace Go { 00021 /*<CPUclock:*/ 00023 class CPUclock 00024 { 00025 double last; // previous clock value 00026 double now; // present clock value 00027 double diff; // diff = now - last 00028 00029 void swap();// last = now 00030 void subt();// subtract: now - last, store in diff 00031 00032 public: 00034 CPUclock (); 00035 00038 double getInterval (); // returns user time 00039 // double getInterval2 (); // returns user time + system time 00040 00043 void initTime () { getInterval(); } 00044 00045 // string report (const string& message); 00046 00048 double getTime (); 00049 }; 00050 00051 };// namespace Go 00052 /*>CPUclock:*/ 00053 00054 /*Class:CPUclock 00055 00056 NAME: CPUclock - measures the CPU time in C++ programs 00057 00058 SYNTAX: @CPUclock 00059 00060 00061 KEYWORDS: 00062 00063 CPU time, clock 00064 00065 00066 DESCRIPTION: 00067 00068 One can get the user time in absolute seconds, or the length of intervals 00069 can be measured (in seconds). 00070 00071 "getTime" - returns time in seconds since January 1, 1970 00072 00073 "initTime" - start measuring the length of an interval (typically called 00074 prior to the computational job to be measured). In fact, 00075 "initTime" is just a call to "getInterval" - the function 00076 was for making programs easier to read. 00077 00078 "getInterval" - returns the length of the user time interval (in seconds) 00079 between the present call to getInterval and the last call 00080 to initTime or to getInterval 00081 00082 "getInterval2" - as "getInterval", but the user time plus the system time 00083 is returned. 00084 00085 "report" - returns a string ("String") containing a message (f.ex. where in 00086 the program the "report" function was called) and the user and 00087 system time since last call to "initTime" or "getInterval" 00088 (or "getInterval2"). 00089 00090 SEE ALSO: 00091 00092 "time.h", "sys/times.h" 00093 00094 DEVELOPED BY: 00095 00096 SINTEF Applied Mathematics, Oslo, Norway, and 00097 University of Oslo, Dept. of Mathematics, Norway 00098 00099 AUTHOR: 00100 00101 Hans Petter Langtangen, SINTEF/UiO 00102 00103 End: 00104 */ 00105 00106 00107 00108 00109 #endif 00110 00111 00112 00113 /* LOG HISTORY of this file: 00114 00115 $Log: not supported by cvs2svn $ 00116 Revision 1.6 2004/04/02 06:06:38 bsp 00117 Bug fix in getTime() 00118 00119 Revision 1.5 2004/01/14 11:19:19 bsp 00120 Added doxygen code 00121 00122 Revision 1.4 2002/08/15 15:05:26 sbr 00123 WinNT compilation fix. 00124 00125 Revision 1.3 2002/04/26 09:30:59 ers 00126 Moved CPUclock from parametrization to utils 00127 00128 Revision 1.1 2000/10/20 10:28:38 afr 00129 First commit. 00130 00131 Revision 1.1 2000/07/06 07:17:27 afr 00132 Added a few new files and changed GoHandle a bit. 00133 00134 * Revision 1.14 1996/11/15 10:58:31 job 00135 * Version 2.4.0 00136 * 00137 */
Generated on Tue Sep 21 15:44:17 2010 for GoTools Core by  doxygen 1.6.3