📄 timesyshms.cc
字号:
/* timesyshms.cc */#ifdef sgi #include <stdio.h> #include <sys/types.h> #include <sys/times.h> #include <time.h> #include <unistd.h> #include "timesyshms.h"#else extern "C" { #include <stdio.h> #include <sys/types.h> #include <sys/times.h> #include <time.h> #include <unistd.h> #include "timesyshms.h" }#endifextern FILE *logFile;extern float idct;/*----------------------------------------------------------------------------*/void timesyshms( Clock duration, struct tms *start, struct tms *end )/*----------------------------------------------------------------------------*/{ int h, m; float t, T, s; const float min = 60., hrs = 3600.; (void)fprintf( logFile, "Real= " ); t = (float)duration * idct; h = (int)(t/hrs); T = t - ((float)h)*hrs; m = (int)(T/min); s = T - ((float)m)*min; if (h == 0) { if (m == 0) (void)fprintf(logFile, "%.2fs", s ); else (void)fprintf(logFile, "%dm %05.2fs", m, s ); } else { (void)fprintf(logFile, "%dh %02dm %05.2fs", h, m, s ); } (void)fprintf( logFile, ", CPU= " ); t = (float)((end->tms_utime - start->tms_utime) * idct); h = (int)(t/hrs); T = t - ((float)h)*hrs; m = (int)(T/min); s = T - ((float)m)*min; if (h == 0) { if (m == 0) (void)fprintf(logFile, "%.2fs", s ); else (void)fprintf(logFile, "%dm %05.2fs", m, s ); } else { (void)fprintf(logFile, "%dh %02dm %05.2fs", h, m, s ); } (void)fprintf( logFile, ", System= " ); t = (float)((end->tms_stime - start->tms_stime) * idct); h = (int)(t/hrs); T = t - ((float)h)*hrs; m = (int)(T/min); s = T - ((float)m)*min; if (h == 0) { if (m == 0) (void)fprintf(logFile, "%.2fs", s ); else (void)fprintf(logFile, "%dm %05.2fs", m, s ); } else { (void)fprintf(logFile, "%dh %02dm %05.2fs", h, m, s ); } (void)fprintf( logFile, "\n" );}/*----------------------------------------------------------------------------*//* EOF. *//*----------------------------------------------------------------------------*/
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -