neuro_toolbox
utility.hpp
Go to the documentation of this file.
1 #ifndef UTILITY_HPP
2 #define UTILITY_HPP
3 
4 #include "config.hpp"
5 
6 namespace NTB
7 {
8  /*------------------------------------------------------------*/
9  double get_wall_time()
10  {
16  struct timeval time;
17  if (gettimeofday(&time, NULL))
18  {
19  // Handle error
20  return 0;
21  }
22  return (double)time.tv_sec + (double)time.tv_usec * .000001;
23  }
24  /*------------------------------------------------------------*/
25  double get_cpu_time()
26  {
32  return (double)clock() / CLOCKS_PER_SEC;
33  }
34  /*------------------------------------------------------------*/
35  void display_timing(double wtime, double cptime)
36  {
41  int wh, ch;
42  int wmin, cpmin;
43  double wsec, csec;
44  wh = (int)wtime / 3600;
45  ch = (int)cptime / 3600;
46  wmin = ((int)wtime % 3600) / 60;
47  cpmin = ((int)cptime % 3600) / 60;
48  wsec = wtime - (3600. * wh + 60. * wmin);
49  csec = cptime - (3600. * ch + 60. * cpmin);
50  printf("Wall Time : %d hours and %d minutes and %.4f seconds.\n", wh, wmin, wsec);
51  printf ("CPU Time : %d hours and %d minutes and %.4f seconds.\n",ch,cpmin,csec);
52  }
53 
54 } // namespace Neuro
55 
56 #endif // !UTILITY_HPP
double get_cpu_time()
Definition: utility.hpp:25
void display_timing(double wtime, double cptime)
Definition: utility.hpp:35
double get_wall_time()
Definition: utility.hpp:9
Definition: IO.hpp:6