Debian Codegraph @

Kernel/procTimer.h

raw symbols SCIP
1 /* This file is part of the FaCT++ DL reasoner
2 Copyright (C) 2003-2015 Dmitry Tsarkov and The University of Manchester
3 Copyright (C) 2015-2017 Dmitry Tsarkov
4
5 This library is free software; you can redistribute it and/or
6 modify it under the terms of the GNU Lesser General Public
7 License as published by the Free Software Foundation; either
8 version 2.1 of the License, or (at your option) any later version.
9
10 This library is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 Lesser General Public License for more details.
14
15 You should have received a copy of the GNU Lesser General Public
16 License along with this library; if not, write to the Free Software
17 Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
18 */
19
20 #ifndef PROCTIMER_H
21 #define PROCTIMER_Hcxx . . $ `Kernel/procTimer.h:21:9`!
22
23 #include <ctime>
24
25 /**
26 * Class TsProcTimer definition & implementation
27 *
28 * Useful for calculating processor time intervals up to 10^-3 sec
29 *
30 */
31 class TsProcTimercxx . . $ TsProcTimer#
32 {
33 private: // members
34 /// save the starting time of the timer
35 clock_tcxx . . $ clock_t# startTimecxx . . $ TsProcTimer#startTime. = 0;
36 /// calculated time between Start() and Stop() calls
37 float resultTimecxx . . $ TsProcTimer#resultTime. = 0.0f;
38 /// flag to show timer is started
39 bool Startedcxx . . $ TsProcTimer#Started. = false;
40
41 private: // methods
42 /// get time interval between startTime and current time
43 float calcDeltacxx . . $ TsProcTimer#calcDelta(5036dfe8d4170af2). ( void ) const;
44
45 public: // interface
46 /// reset timer
47 void Resetcxx . . $ TsProcTimer#Reset(49f6e7a06ebc5aa8). ( void );
48
49 /// record current time
50 void Startcxx . . $ TsProcTimer#Start(49f6e7a06ebc5aa8). ( void );
51 /// save time interval from starting point to current moment
52 void Stopcxx . . $ TsProcTimer#Stop(49f6e7a06ebc5aa8). ( void );
53
54 /// get time interval
55 operatorcxx . . $ TsProcTimer#`operator float`(5036dfe8d4170af2). float ( void ) const;
56 }; // TsProcTimer
57
58 /**
59 * TsTimer implementation
60 */
61
62 inline void TsProcTimercxx . . $ TsProcTimer# :: Resetcxx . . $ TsProcTimer#Reset(49f6e7a06ebc5aa8). ( void )
63 {
64 Startedcxx . . $ TsProcTimer#Started. = false;
65 resultTimecxx . . $ TsProcTimer#resultTime. = 0;
66 }
67
68 inline float TsProcTimercxx . . $ TsProcTimer# :: calcDeltacxx . . $ TsProcTimer#calcDelta(5036dfe8d4170af2). ( void ) const
69 {
70 clock_tcxx . . $ clock_t# finishTime = clock();
71
72 // calculate difference between current time and start time
73 float realProcTime = float(finishTime>=startTimecxx . . $ TsProcTimer#startTime. ?
74 finishTime-startTimecxx . . $ TsProcTimer#startTime. :
75 ((clock_tcxx . . $ clock_t#)-1)-startTimecxx . . $ TsProcTimer#startTime.+finishTime ) / CLOCKS_PER_SECcxx . . $ __clock_t#;
76
77 // correct times less than a millisecond
78 if ( realProcTime < 1e-3 )
79 realProcTime = 0;
80
81 return realProcTime;
82 }
83
84 inline TsProcTimercxx . . $ TsProcTimer# :: operatorcxx . . $ TsProcTimer#`operator float`(5036dfe8d4170af2). float ( void ) const
85 {
86 const unsigned int norm = 100; // normalisation constant
87 float realProcTime;
88
89 if ( Startedcxx . . $ TsProcTimer#Started. )
90 realProcTime = calcDeltacxx . . $ TsProcTimer#calcDelta(5036dfe8d4170af2).();
91 else
92 realProcTime = resultTimecxx . . $ TsProcTimer#resultTime.;
93
94 // normalise value up to CONST
95 return ((unsigned long)(realProcTime*norm))/(float)norm;
96 }
97
98 inline void TsProcTimercxx . . $ TsProcTimer# :: Startcxx . . $ TsProcTimer#Start(49f6e7a06ebc5aa8). ( void )
99 {
100 if ( !Startedcxx . . $ TsProcTimer#Started. )
101 {
102 startTimecxx . . $ TsProcTimer#startTime. = clock();
103 Startedcxx . . $ TsProcTimer#Started. = true;
104 }
105 }
106
107 inline void TsProcTimercxx . . $ TsProcTimer# :: Stopcxx . . $ TsProcTimer#Stop(49f6e7a06ebc5aa8). ( void )
108 {
109 if ( Startedcxx . . $ TsProcTimer#Started. )
110 {
111 Startedcxx . . $ TsProcTimer#Started. = false;
112 resultTimecxx . . $ TsProcTimer#resultTime. += calcDeltacxx . . $ TsProcTimer#calcDelta(5036dfe8d4170af2). ();
113 }
114 }
115
116 #endif