My Project
Loading...
Searching...
No Matches
timer.h File Reference

Go to the source code of this file.

Functions

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

Variables

EXTERN_VAR int timerv
 
EXTERN_VAR int rtimerv
 

Function Documentation

◆ getRTimer()

int getRTimer ( )

Definition at line 150 of file timer.cc.

151{
152 struct timeval now;
153
154 gettimeofday(&now, &tzp);
155
156 if (startRl.tv_usec > now.tv_usec)
157 {
158 now.tv_usec += 1000000;
159 now.tv_sec --;
160 }
161
162 double f =((double) (now.tv_sec - startRl.tv_sec))*timer_resolution +
163 ((double) (now.tv_usec - startRl.tv_usec))*timer_resolution /
164 (double) 1000000;
165
166 return (int)(f+0.5);
167}
FILE * f
Definition checklibs.c:9
STATIC_VAR double timer_resolution
Definition timer.cc:18
STATIC_VAR struct timeval startRl
Definition timer.cc:127
STATIC_VAR struct timezone tzp
Definition timer.cc:129

◆ getTimer()

long getTimer ( )

Definition at line 80 of file timer.cc.

81{
82 int64 curr;
83 getrusage(RUSAGE_SELF,&t_rec);
84 curr = (int64)t_rec.ru_utime.tv_sec*1000000+(int64)t_rec.ru_utime.tv_usec
85 +(int64)t_rec.ru_stime.tv_sec*1000000+(int64)t_rec.ru_stime.tv_usec;
86 getrusage(RUSAGE_CHILDREN,&t_rec);
87 curr += (int64)t_rec.ru_utime.tv_sec*1000000+(int64)t_rec.ru_utime.tv_usec
88 +(int64)t_rec.ru_stime.tv_sec*1000000+(int64)t_rec.ru_stime.tv_usec;
89 double f = ((double)curr) * timer_resolution / (double)1000000;
90 return (long)(f+0.5);
91}
long int64
Definition auxiliary.h:68
STATIC_VAR struct rusage t_rec
Definition timer.cc:63

◆ initRTimer()

void initRTimer ( )

Definition at line 136 of file timer.cc.

137{
138#ifdef HAVE_GETTIMEOFDAY
139 gettimeofday(&startRl, &tzp);
140 gettimeofday(&siStartRTime, &tzp);
141#else
142 memset(&startRl,0,sizeof(startRl));
143 memset(&siStartRTime,0,sizeof(siStartRTime));
144#endif
145}
STATIC_VAR struct timeval siStartRTime
Definition timer.cc:128

◆ 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 131 of file timer.cc.

132{
133 gettimeofday(&siStartRTime, &tzp);
134}

◆ startTimer()

int startTimer ( void )

Definition at line 66 of file timer.cc.

67{
68 getrusage(RUSAGE_SELF,&t_rec);
69 siStartTime = (int64)t_rec.ru_utime.tv_sec*1000000+(int64)t_rec.ru_utime.tv_usec
70 +(int64)t_rec.ru_stime.tv_sec*1000000+(int64)t_rec.ru_stime.tv_usec;
71 getrusage(RUSAGE_CHILDREN,&t_rec);
72 siStartTime += (int64)t_rec.ru_utime.tv_sec*1000000+(int64)t_rec.ru_utime.tv_usec
73 +(int64)t_rec.ru_stime.tv_sec*1000000+(int64)t_rec.ru_stime.tv_usec;
74 return (int)time(NULL);
75}
#define NULL
Definition omList.c:12
STATIC_VAR int64 siStartTime
Definition timer.cc:58

◆ writeRTime()

void writeRTime ( const char * s)

Definition at line 173 of file timer.cc.

174{
175 struct timeval now;
176
177 gettimeofday(&now, &tzp);
178
179 if (siStartRTime.tv_usec > now.tv_usec)
180 {
181 now.tv_usec += 1000000;
182 now.tv_sec --;
183 }
184
185 double f =((double) (now.tv_sec - siStartRTime.tv_sec)) +
186 ((double) (now.tv_usec - siStartRTime.tv_usec)) /
187 (double) 1000000;
188
189 if (f > mintime)
190 Print("//%s %.2f sec \n" ,v ,f);
191}
#define Print
Definition emacs.cc:80
const Variable & v
< [in] a sqrfree bivariate poly
Definition facBivar.h:39

◆ writeTime()

void writeTime ( const char * s)

Definition at line 101 of file timer.cc.

102{
103 int64 curr;
104 getrusage(RUSAGE_SELF,&t_rec);
105 curr = (int64)t_rec.ru_utime.tv_sec*1000000+(int64)t_rec.ru_utime.tv_usec
106 +(int64)t_rec.ru_stime.tv_sec*1000000+(int64)t_rec.ru_stime.tv_usec;
107 getrusage(RUSAGE_CHILDREN,&t_rec);
108 curr += (int64)t_rec.ru_utime.tv_sec*1000000+(int64)t_rec.ru_utime.tv_usec
109 +(int64)t_rec.ru_stime.tv_sec*1000000+(int64)t_rec.ru_stime.tv_usec;
110 curr -= siStartTime;
111 double f = ((double)curr) * timer_resolution / (double)1000000;
113 {
114#ifdef EXTEND_TIMER_D
115 Print("//%s %.2f/%d sec (%d) >>%s<<\n" ,v ,f,(int)timer_resolution,iiOp,my_yylinebuf);
116#else
117 if (timer_resolution==(double)1.0)
118 Print("//%s %.2f sec\n" ,v ,f);
119 else
120 Print("//%s %.2f/%d sec\n" ,v ,f,(int)timer_resolution);
121#endif
122 }
123}
VAR char my_yylinebuf[80]
Definition febase.cc:44
VAR int iiOp
Definition iparith.cc:218

Variable Documentation

◆ rtimerv

EXTERN_VAR int rtimerv

Definition at line 16 of file timer.h.

◆ timerv

EXTERN_VAR int timerv

Definition at line 10 of file timer.h.