generic.c
来自「Parallel programming/Lou Baker, Bradley 」· C语言 代码 · 共 65 行
C
65 行
#ifdef TIMES
void
InitSysTimer(PSysTimer pt)
{
pt->cur_tot.tms_utime = 0;
pt->cur_tot.tms_stime = 0;
pt->cur_tot.tms_cutime = 0;
pt->cur_tot.tms_cstime = 0;
pt->running = FALSE;
}
void
StartSysTimer(PSysTimer pt)
{
#ifdef DEBUG
if(pt->running)
Debug("WARNING - restarted running timer!\n");
#endif
times(&pt->last_start);
pt->running = TRUE;
}
void
StopSysTimer(PSysTimer pt)
{
struct tms end;
if(!pt->running)
{
#ifdef DEBUG
Debug("WARNING: StopSysTimer called on stopped timer!\n");
#endif
return;
}
pt->running = FALSE;
times(&end);
/* Running total of user and system times */
pt->cur_tot.tms_utime += end.tms_utime - pt->last_start.tms_utime;
pt->cur_tot.tms_stime += end.tms_stime - pt->last_start.tms_stime;
}
void
SPrintSysTimer(char *s, PSysTimer pt, int fmt)
{
sprintf(s,"%f sec", (fmt == ST_SYS_TIME?
((float)pt->cur_tot.tms_stime/100.0) :
((float)pt->cur_tot.tms_utime/100.0) ) );
}
void
NormalizeTime(clock_t *t)
{
long tim;
/* Normalize times to 10ths of a second */
tim = (long) *t;
tim = (tim * 10L)/CLK_TCK;
*t = (clock_t) tim;
}
#endif /* TIMES */
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?