wkfutils.h File Reference

Go to the source code of this file.

Classes

struct  wkfmsgtimer

Defines

#define WKF_UTILS_INC   1

Typedefs

typedef void * wkf_timerhandle

Functions

wkf_timerhandle wkf_timer_create (void)
void wkf_timer_destroy (wkf_timerhandle)
void wkf_timer_start (wkf_timerhandle)
void wkf_timer_stop (wkf_timerhandle)
double wkf_timer_time (wkf_timerhandle)
double wkf_timer_timenow (wkf_timerhandle)
double wkf_timer_start_time (wkf_timerhandle)
double wkf_timer_stop_time (wkf_timerhandle)
wkfmsgtimerwkf_msg_timer_create (double updatetime)
int wkf_msg_timer_timeout (wkfmsgtimer *time)
void wkf_msg_timer_destroy (wkfmsgtimer *mt)


Define Documentation

#define WKF_UTILS_INC   1

Definition at line 43 of file wkfutils.h.


Typedef Documentation

typedef void* wkf_timerhandle

a timer handle

Definition at line 49 of file wkfutils.h.


Function Documentation

wkfmsgtimer* wkf_msg_timer_create ( double  updatetime  ) 

initialize status message timer

Definition at line 178 of file wkfutils.c.

References wkfmsgtimer::timer, wkfmsgtimer::updatetime, wkf_timer_create(), and wkf_timer_start().

00178                                                       {
00179   wkfmsgtimer *mt;
00180   mt = (wkfmsgtimer *) malloc(sizeof(wkfmsgtimer));
00181   if (mt != NULL) {
00182     mt->timer = wkf_timer_create();
00183     mt->updatetime = updatetime;
00184     wkf_timer_start(mt->timer);
00185   }
00186   return mt;
00187 }

void wkf_msg_timer_destroy ( wkfmsgtimer mt  ) 

destroy message timer

Definition at line 204 of file wkfutils.c.

References wkfmsgtimer::timer, and wkf_timer_destroy().

00204                                              {
00205   wkf_timer_destroy(mt->timer);
00206   free(mt);
00207 }

int wkf_msg_timer_timeout ( wkfmsgtimer mt  ) 

return true if it's time to print a status update message

Definition at line 190 of file wkfutils.c.

References wkfmsgtimer::timer, wkfmsgtimer::updatetime, wkf_timer_start(), and wkf_timer_timenow().

00190                                            {
00191   double elapsed = wkf_timer_timenow(mt->timer);
00192   if (elapsed > mt->updatetime) {
00193     /* reset the clock and return true that our timer expired */
00194     wkf_timer_start(mt->timer);
00195     return 1;
00196   } else if (elapsed < 0) {
00197     /* time went backwards, best reset our clock! */
00198     wkf_timer_start(mt->timer);
00199   }
00200   return 0;
00201 }

wkf_timerhandle wkf_timer_create ( void   ) 

create a timer (clears timer)

Definition at line 161 of file wkfutils.c.

Referenced by NL_msm_create(), and wkf_msg_timer_create().

00161                                        {
00162   wkf_timer * t;
00163   t = (wkf_timer *) malloc(sizeof(wkf_timer));
00164   memset(t, 0, sizeof(wkf_timer));
00165   return t;
00166 }

void wkf_timer_destroy ( wkf_timerhandle   ) 

create a timer (clears timer)

Definition at line 168 of file wkfutils.c.

Referenced by NL_msm_destroy(), and wkf_msg_timer_destroy().

00168                                           {
00169   free(v);
00170 }

void wkf_timer_start ( wkf_timerhandle   ) 

start a timer (clears timer)

Definition at line 124 of file wkfutils.c.

References wkf_timer::tz.

Referenced by NL_msm_compute_force(), NL_msm_compute_force_sprec(), NL_msm_compute_long_range(), NL_msm_compute_long_range_sprec(), wkf_msg_timer_create(), and wkf_msg_timer_timeout().

00124                                         {
00125   wkf_timer * t = (wkf_timer *) v;
00126   gettimeofday(&t->starttime, &t->tz);
00127 }

double wkf_timer_start_time ( wkf_timerhandle   ) 

report wall starting time

Definition at line 142 of file wkfutils.c.

00142                                                {
00143   wkf_timer * t = (wkf_timer *) v;
00144   double ttime;
00145   ttime = ((double) t->starttime.tv_sec) +
00146           ((double) t->starttime.tv_usec) / 1000000.0;
00147   return ttime;
00148 }

void wkf_timer_stop ( wkf_timerhandle   ) 

stop a timer

Definition at line 129 of file wkfutils.c.

References wkf_timer::endtime, and wkf_timer::tz.

Referenced by NL_msm_compute_force(), NL_msm_compute_force_sprec(), NL_msm_compute_long_range(), NL_msm_compute_long_range_sprec(), and wkf_timer_timenow().

00129                                        {
00130   wkf_timer * t = (wkf_timer *) v;
00131   gettimeofday(&t->endtime, &t->tz);
00132 }

double wkf_timer_stop_time ( wkf_timerhandle   ) 

report wall stopping time

Definition at line 150 of file wkfutils.c.

References wkf_timer::endtime.

00150                                               {
00151   wkf_timer * t = (wkf_timer *) v;
00152   double ttime;
00153   ttime = ((double) t->endtime.tv_sec) +
00154           ((double) t->endtime.tv_usec) / 1000000.0;
00155   return ttime;
00156 }

double wkf_timer_time ( wkf_timerhandle   ) 

report elapsed time in seconds

Definition at line 134 of file wkfutils.c.

References wkf_timer::endtime.

Referenced by NL_msm_compute_force(), NL_msm_compute_force_sprec(), NL_msm_compute_long_range(), NL_msm_compute_long_range_sprec(), and wkf_timer_timenow().

00134                                          {
00135   wkf_timer * t = (wkf_timer *) v;
00136   double ttime;
00137   ttime = ((double) (t->endtime.tv_sec - t->starttime.tv_sec)) +
00138           ((double) (t->endtime.tv_usec - t->starttime.tv_usec)) / 1000000.0;
00139   return ttime;
00140 }

double wkf_timer_timenow ( wkf_timerhandle   ) 

report elapsed time in seconds

Definition at line 172 of file wkfutils.c.

References wkf_timer_stop(), and wkf_timer_time().

Referenced by wkf_msg_timer_timeout().

00172                                             {
00173   wkf_timer_stop(v);
00174   return wkf_timer_time(v);
00175 }


Generated on Sat Sep 23 01:17:17 2017 for NAMD by  doxygen 1.4.7