Carmen Code
 All Classes Files Functions Variables Macros Pages
Functions
ShowTime.cpp File Reference

Computes the CPU Time. More...

#include "Carmen.h"
Include dependency graph for ShowTime.cpp:

Functions

void ShowTime (Timer arg)
 Writes on screen the estimation of total and remaining CPU times. These informations are stored in the timer arg. More...
 

Detailed Description

Computes the CPU Time.

Function Documentation

void ShowTime ( Timer  arg)

Writes on screen the estimation of total and remaining CPU times. These informations are stored in the timer arg.

Parameters
argArgument
Returns
void
24 {
25 // double ftime; // real time
26  double ctime; // CPU time
27 // unsigned int ttime, rtime; // total and remaining real time (in seconds)
28  unsigned int tctime, rctime; // total and remaining CPU time (in seconds)
29 
30  int day, hour, min, sec;
31  unsigned int rest;
32 
33  // --- Write total and remaining estimated time -----------------------
34 
35 // ftime = arg.GetRealTime();
36  ctime = arg.CPUTime();
37 // ttime = (unsigned int)((ftime*IterationNb)/IterationNo);
38 // rtime = (unsigned int)((ftime*(IterationNb-IterationNo))/IterationNo);
39  tctime = (unsigned int)((ctime*IterationNb)/IterationNo);
40  rctime = (unsigned int)((ctime*(IterationNb-IterationNo))/IterationNo);
41 
42  // --- Show total time ------------------------------------------------
43 
44  rest = tctime;
45  day = rest/86400;
46  rest %= 86400;
47  hour = rest/3600;
48  rest %= 3600;
49  min = rest/60;
50  rest %= 60;
51  sec = rest;
52 
53  printf("\033[1A\033[1A");
54 
55  if (tctime >= 86400)
56  printf("Total CPU time (estimation) : %5d day %2d h %2d min %2d s\n", day, hour, min, sec);
57 
58  if ((tctime < 86400)&&(tctime >= 3600))
59  printf("Total CPU time (estimation) : %2d h %2d min %2d s \n", hour, min, sec);
60 
61  if ((tctime < 3600)&&(tctime >= 60))
62  printf("Total CPU time (estimation) : %2d min %2d s \n", min, sec);
63 
64  if (tctime < 60)
65  printf("Total CPU time (estimation) : %2d s \n", sec);
66 
67  // --- Show remaining time ------------------------------------------------
68 
69  rest = rctime;
70  day = rest/86400;
71  rest %= 86400;
72  hour = rest/3600;
73  rest %= 3600;
74  min = rest/60;
75  rest %= 60;
76  sec = rest;
77 
78  if (rctime >= 86400)
79  printf("Remaining CPU time (estimation) : %5d day %2d h %2d min %2d s\n", day, hour, min, sec);
80 
81  if ((rctime < 86400)&&(rctime >= 3600))
82  printf("Remaining CPU time (estimation) : %2d h %2d min %2d s \n", hour, min, sec);
83 
84  if ((rctime < 3600)&&(rctime >= 60))
85  printf("Remaining CPU time (estimation) : %2d min %2d s \n", min, sec);
86 
87  if (rctime < 60)
88  printf("Remaining CPU time (estimation) : %2d s \n", sec);
89 
90 }
int IterationNb
Definition: Parameters.cpp:37
double CPUTime()
Returns CPU time from previous start in seconds.
Definition: Timer.cpp:124
int IterationNo
Definition: Parameters.cpp:168

Here is the caller graph for this function: