My Project
Loading...
Searching...
No Matches
Functions | Variables
timer.cc File Reference
#include "kernel/mod2.h"
#include <sys/resource.h>
#include <unistd.h>
#include <stdio.h>
#include <time.h>
#include <sys/time.h>
#include "reporter/reporter.h"
#include "kernel/oswrapper/timer.h"

Go to the source code of this file.

Functions

void SetTimerResolution (int res)
 
void SetMinDisplayTime (double mtime)
 
int initTimer ()
 
void startTimer ()
 
int getTimer ()
 
void writeTime (const char *v)
 
void startRTimer ()
 
void initRTimer ()
 
int getRTimer ()
 
void writeRTime (const char *v)
 

Variables

VAR int timerv = 0
 
STATIC_VAR double timer_resolution = TIMER_RESOLUTION
 
STATIC_VAR double mintime = 0.5
 
STATIC_VAR int64 siStartTime
 
STATIC_VAR int64 startl
 
STATIC_VAR struct rusage t_rec
 
VAR int rtimerv = 0
 
STATIC_VAR struct timeval startRl
 
STATIC_VAR struct timeval siStartRTime
 
STATIC_VAR struct timezone tzp
 

Function Documentation

◆ getRTimer()

int getRTimer ( )

Definition at line 170 of file timer.cc.

171{
172 struct timeval now;
173
174 gettimeofday(&now, &tzp);
175
176 if (startRl.tv_usec > now.tv_usec)
177 {
178 now.tv_usec += 1000000;
179 now.tv_sec --;
180 }
181
182 double f =((double) (now.tv_sec - startRl.tv_sec))*timer_resolution +
183 ((double) (now.tv_usec - startRl.tv_usec))*timer_resolution /
184 (double) 1000000;
185
186 return (int)(f+0.5);
187}
FILE * f
Definition: checklibs.c:9
STATIC_VAR double timer_resolution
Definition: timer.cc:18
STATIC_VAR struct timeval startRl
Definition: timer.cc:147
STATIC_VAR struct timezone tzp
Definition: timer.cc:149

◆ getTimer()

int getTimer ( )

Definition at line 95 of file timer.cc.

96{
97 int64 curr;
98 getrusage(RUSAGE_SELF,&t_rec);
99 curr = ((int64)t_rec.ru_utime.tv_sec*1000000+(int64)t_rec.ru_utime.tv_usec
100 +(int64)t_rec.ru_stime.tv_sec*1000000+(int64)t_rec.ru_stime.tv_usec
101 +(int64)5000)/(int64)10000; // unit is 1/100 sec
102 getrusage(RUSAGE_CHILDREN,&t_rec);
103 curr += ((int64)t_rec.ru_utime.tv_sec*1000000+(int64)t_rec.ru_utime.tv_usec
104 +(int64)t_rec.ru_stime.tv_sec*1000000+(int64)t_rec.ru_stime.tv_usec
105 +(int64)5000)/(int64)10000; // unit is 1/100 sec
106 curr -= siStartTime;
107 double f = ((double)curr) * timer_resolution / (double)100;
108 return (int)(f+0.5);
109}
long int64
Definition: auxiliary.h:68
STATIC_VAR struct rusage t_rec
Definition: timer.cc:64
STATIC_VAR int64 siStartTime
Definition: timer.cc:58

◆ initRTimer()

void initRTimer ( )

Definition at line 156 of file timer.cc.

157{
158#ifdef HAVE_GETTIMEOFDAY
159 gettimeofday(&startRl, &tzp);
160 gettimeofday(&siStartRTime, &tzp);
161#else
162 memset(&startRl,0,sizeof(startRl));
163 memset(&siStartRTime,0,sizeof(siStartRTime));
164#endif
165}
STATIC_VAR struct timeval siStartRTime
Definition: timer.cc:148

◆ initTimer()

int initTimer ( )

Definition at line 67 of file timer.cc.

68{
69 getrusage(RUSAGE_SELF,&t_rec);
70 siStartTime = (t_rec.ru_utime.tv_sec*1000000+t_rec.ru_utime.tv_usec
71 +t_rec.ru_stime.tv_sec*1000000+t_rec.ru_stime.tv_usec
72 +5000)/10000; // unit is 1/100 sec
73 getrusage(RUSAGE_CHILDREN,&t_rec);
74 siStartTime += (t_rec.ru_utime.tv_sec*1000000+t_rec.ru_utime.tv_usec
75 +t_rec.ru_stime.tv_sec*1000000+t_rec.ru_stime.tv_usec
76 +5000)/10000; // unit is 1/100 sec
77 return (int)time(NULL);
78}
#define NULL
Definition: omList.c:12

◆ SetMinDisplayTime()

void SetMinDisplayTime ( double  mtime)

Definition at line 27 of file timer.cc.

28{
29 mintime = mtime;
30}
STATIC_VAR double mintime
Definition: timer.cc:20

◆ SetTimerResolution()

void SetTimerResolution ( int  res)

Definition at line 22 of file timer.cc.

23{
24 timer_resolution = (double) res;
25}
CanonicalForm res
Definition: facAbsFact.cc:60

◆ startRTimer()

void startRTimer ( void  )

Definition at line 151 of file timer.cc.

152{
153 gettimeofday(&siStartRTime, &tzp);
154}

◆ startTimer()

void startTimer ( void  )

Definition at line 80 of file timer.cc.

81{
82 getrusage(RUSAGE_SELF,&t_rec);
83 startl = ((int64)t_rec.ru_utime.tv_sec*1000000+(int64)t_rec.ru_utime.tv_usec
84 +(int64)t_rec.ru_stime.tv_sec*1000000+t_rec.ru_stime.tv_usec
85 +(int64)5000)/(int64)10000; // unit is 1/100 sec
86 getrusage(RUSAGE_CHILDREN,&t_rec);
87 startl += ((int64)t_rec.ru_utime.tv_sec*1000000+(int64)t_rec.ru_utime.tv_usec
88 +(int64)t_rec.ru_stime.tv_sec*1000000+t_rec.ru_stime.tv_usec
89 +(int64)5000)/(int64)10000; // unit is 1/100 sec
90}
STATIC_VAR int64 startl
Definition: timer.cc:59

◆ writeRTime()

void writeRTime ( const char *  v)

Definition at line 193 of file timer.cc.

194{
195 struct timeval now;
196
197 gettimeofday(&now, &tzp);
198
199 if (siStartRTime.tv_usec > now.tv_usec)
200 {
201 now.tv_usec += 1000000;
202 now.tv_sec --;
203 }
204
205 double f =((double) (now.tv_sec - siStartRTime.tv_sec)) +
206 ((double) (now.tv_usec - siStartRTime.tv_usec)) /
207 (double) 1000000;
208
209 if (f > mintime)
210 Print("//%s %.2f sec \n" ,v ,f);
211}
#define Print
Definition: emacs.cc:80
const Variable & v
< [in] a sqrfree bivariate poly
Definition: facBivar.h:39

◆ writeTime()

void writeTime ( const char *  v)

Definition at line 119 of file timer.cc.

120{
121 int64 curr;
122 getrusage(RUSAGE_SELF,&t_rec);
123 curr = ((int64)t_rec.ru_utime.tv_sec*1000000+(int64)t_rec.ru_utime.tv_usec
124 +(int64)t_rec.ru_stime.tv_sec*1000000+(int64)t_rec.ru_stime.tv_usec
125 +(int64)5000)/(int64)10000; // unit is 1/100 sec
126 getrusage(RUSAGE_CHILDREN,&t_rec);
127 curr += ((int64)t_rec.ru_utime.tv_sec*1000000+(int64)t_rec.ru_utime.tv_usec
128 +(int64)t_rec.ru_stime.tv_sec*1000000+(int64)t_rec.ru_stime.tv_usec
129 +(int64)5000)/(int64)10000; // unit is 1/100 sec
130 curr -= startl;
131 double f = ((double)curr) * timer_resolution / (double)100;
133 {
134#ifdef EXTEND_TIMER_D
135 Print("//%s %.2f/%d sec (%d) >>%s<<\n" ,v ,f,(int)timer_resolution,iiOp,my_yylinebuf);
136#else
137 if (timer_resolution==(double)1.0)
138 Print("//%s %.2f sec\n" ,v ,f);
139 else
140 Print("//%s %.2f/%d sec\n" ,v ,f,(int)timer_resolution);
141#endif
142 }
143}
VAR char my_yylinebuf[80]
Definition: febase.cc:44
VAR int iiOp
Definition: iparith.cc:222

Variable Documentation

◆ mintime

STATIC_VAR double mintime = 0.5

Definition at line 20 of file timer.cc.

◆ rtimerv

VAR int rtimerv = 0

Definition at line 146 of file timer.cc.

◆ siStartRTime

STATIC_VAR struct timeval siStartRTime

Definition at line 148 of file timer.cc.

◆ siStartTime

STATIC_VAR int64 siStartTime

Definition at line 58 of file timer.cc.

◆ startl

STATIC_VAR int64 startl

Definition at line 59 of file timer.cc.

◆ startRl

STATIC_VAR struct timeval startRl

Definition at line 147 of file timer.cc.

◆ t_rec

STATIC_VAR struct rusage t_rec

Definition at line 64 of file timer.cc.

◆ timer_resolution

STATIC_VAR double timer_resolution = TIMER_RESOLUTION

Definition at line 18 of file timer.cc.

◆ timerv

VAR int timerv = 0

Definition at line 17 of file timer.cc.

◆ tzp

STATIC_VAR struct timezone tzp

Definition at line 149 of file timer.cc.