Class documentation of Concepts

Loading...
Searching...
No Matches
resourceMonitor.hh
Go to the documentation of this file.
1
6#ifndef resourceMonitor_hh
7#define resourceMonitor_hh
8
9#include <iostream>
10
11#include <sys/time.h>
12#include <sys/resource.h>
13#include <unistd.h>
14#include <string.h>
15#include <time.h>
16
17extern "C" {
18#ifdef __sun__
19 // Solaris 2.5 does not have getrusage in <sys/resource.h>
20 int getrusage(int who, struct rusage* ru);
21#endif
22}
23
24namespace concepts {
25
26 // ******************************************************* ResourceMonitor **
27
30 friend std::ostream& operator <<(std::ostream& os, ResourceMonitor& rm) {
31 return rm.sample(os); }
32
36 rusage ru_;
37 public:
42
56 std::ostream& sample(std::ostream& os);
57
61 float utime();
62 };
63
64}
65
66 // ******************************************************** ResourceTimer **
67
72public:
73
75 memset(&t_old, 0, sizeof(t_old));
76 memset(&t_cur, 0, sizeof(t_cur));
77 start();
78 }
79
80 ~ResourceTimer() { }
81
82 void start();
83 double stop(int nrun = 1);
84
85 double reset(int nrun = 1) {
86 double t = stop(nrun);
87 //start();
88 t_old = t_cur;
89 return t;
90 }
91
92
93 timespec t_old;
94 timespec t_cur;
95};
96
97#endif // resourceMonitor_hh
Timer and resource monitor.
std::ostream & sample(std::ostream &os)
Set< F > makeSet(uint n, const F &first,...)
Definition set.hh:320