|
||||
File indexing completed on 2025-01-18 09:59:05
0001 // 0002 // ******************************************************************** 0003 // * License and Disclaimer * 0004 // * * 0005 // * The Geant4 software is copyright of the Copyright Holders of * 0006 // * the Geant4 Collaboration. It is provided under the terms and * 0007 // * conditions of the Geant4 Software License, included in the file * 0008 // * LICENSE and available at http://cern.ch/geant4/license . These * 0009 // * include a list of copyright holders. * 0010 // * * 0011 // * Neither the authors of this software system, nor their employing * 0012 // * institutes,nor the agencies providing financial support for this * 0013 // * work make any representation or warranty, express or implied, * 0014 // * regarding this software system or assume any liability for its * 0015 // * use. Please see the license in the file LICENSE and URL above * 0016 // * for the full disclaimer and the limitation of liability. * 0017 // * * 0018 // * This code implementation is the result of the scientific and * 0019 // * technical work of the GEANT4 collaboration. * 0020 // * By using, copying, modifying or distributing the software (or * 0021 // * any work based on the software) you agree to acknowledge its * 0022 // * use in resulting scientific publications, and indicate your * 0023 // * acceptance of all terms of the Geant4 Software license. * 0024 // ******************************************************************** 0025 // 0026 // G4SliceTimer 0027 // 0028 // Class description: 0029 // 0030 // Class for timer objects, able to measure elasped user/system process 0031 // accumulated time. 0032 // 0033 // Note: Uses <sys/times.h> & <unistd.h> - POSIX.1 defined 0034 // If used, this header must be included in the source (.cc) file 0035 // and it must be the first header file to be included! 0036 0037 // Author: M.Asai, 23.10.06 - Derived from G4Timer implementation 0038 // -------------------------------------------------------------------- 0039 #ifndef G4SLICE_TIMER_HH 0040 #define G4SLICE_TIMER_HH 1 0041 0042 #if !(defined(WIN32) || defined(__MINGW32__)) 0043 # include <sys/times.h> 0044 # include <unistd.h> 0045 #else 0046 # include <time.h> 0047 # define _SC_CLK_TCK 1 0048 0049 extern "C" 0050 { 0051 int sysconf(int); 0052 }; 0053 0054 // Structure returned by times() 0055 // 0056 struct tms 0057 { 0058 clock_t tms_utime; /* user time */ 0059 clock_t tms_stime; /* system time */ 0060 clock_t tms_cutime; /* user time, children */ 0061 clock_t tms_cstime; /* system time, children */ 0062 }; 0063 0064 extern "C" 0065 { 0066 extern clock_t times(struct tms*); 0067 }; 0068 #endif /* WIN32 */ 0069 0070 #include "G4Types.hh" 0071 #include "G4ios.hh" 0072 0073 class G4SliceTimer 0074 { 0075 public: 0076 G4SliceTimer(); 0077 // Construct a timer object 0078 0079 inline void Start(); 0080 // Start timing 0081 inline void Stop(); 0082 // Stop timing 0083 inline void Clear(); 0084 // Clear accumulated times 0085 inline G4bool IsValid() const; 0086 // Return true if have a valid time (ie start() and stop() called) 0087 G4double GetRealElapsed() const; 0088 // Return the elapsed real time between last calling start() and stop() 0089 G4double GetSystemElapsed() const; 0090 // Return the elapsed system time between last calling start() and stop() 0091 G4double GetUserElapsed() const; 0092 // Return the elapsed user time between last calling start() and stop() 0093 0094 private: 0095 clock_t fStartRealTime, fEndRealTime; 0096 // Real times (arbitrary time 0) 0097 tms fStartTimes, fEndTimes; 0098 // Timing structures (see times(2)) for start and end times 0099 0100 G4double fRealElapsed = 0.0, fSystemElapsed = 0.0, fUserElapsed = 0.0; 0101 0102 G4bool fValidTimes = true; 0103 // True after start and stop have both been called more than once and 0104 // an equal number of times 0105 }; 0106 0107 std::ostream& operator<<(std::ostream& os, const G4SliceTimer& t); 0108 // Print the elapsed real,system and usertimes on os. Prints **s for times 0109 // if !IsValid 0110 0111 #include "G4SliceTimer.icc" 0112 0113 #endif
[ Source navigation ] | [ Diff markup ] | [ Identifier search ] | [ general search ] |
This page was automatically generated by the 2.3.7 LXR engine. The LXR team |