All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
ProcStats.h
Go to the documentation of this file.
1 // $Id: ProcStats.h,v 1.2 2004/06/08 13:40:07 mato Exp $
2 #ifndef GAUDIAUD_PROCSTATS_H
3 #define GAUDIAUD_PROCSTATS_H
4 
5 // Class: ProcStats
6 // Description: Keeps statistics on memory usage
7 // Author: Jim Kowalkowski (FNAL), modified by M. Shapiro (LBNL)
8 
9 #include <string>
10 #include <vector>
11 
12 struct procInfo
13 {
14  procInfo() : vsize(0), rss(0) {}
15  procInfo(double sz, double rss_sz): vsize(sz),rss(rss_sz) {}
16 
17  bool operator==(const procInfo& p) const {
18 #ifdef __ICC
19 // disable icc remark #1572: floating-point equality and inequality comparisons are unreliable
20 #pragma warning(push)
21 #pragma warning(disable:1572)
22 #endif
23 
24  return vsize==p.vsize && rss==p.rss;
25 
26 #ifdef __ICC
27 // re-enable icc remark #1572
28 #pragma warning(pop)
29 #endif
30  }
31 
32  // see proc(4) man pages for units and a description
33  double vsize; // in MB (used to be in pages?)
34  double rss; // in MB (used to be in pages?)
35 };
36 
37 class ProcStats
38 {
39 public:
40  static ProcStats* instance();
41 
42  bool fetch(procInfo& fill_me);
43  double pageSize() const { return pg_size; }
44 
45 private:
46  ProcStats();
47  ~ProcStats();
48 
49  struct cleanup
50  {
51  cleanup() { }
52  ~cleanup();
53  };
54 
55  friend struct cleanup;
56 
57  int fd;
58  double pg_size;
60  std::string fname;
61  char buf[500];
62  bool valid;
63 
64  static ProcStats* inst;
65 };
66 
67 #endif
68 
static ProcStats * inst
Definition: ProcStats.h:64
static ProcStats * instance()
Definition: ProcStats.cpp:240
bool operator==(const procInfo &p) const
Definition: ProcStats.h:17
double pg_size
Definition: ProcStats.h:58
procInfo curr
Definition: ProcStats.h:59
std::string fname
Definition: ProcStats.h:60
int fd
Definition: ProcStats.h:57
double rss
Definition: ProcStats.h:34
procInfo(double sz, double rss_sz)
Definition: ProcStats.h:15
bool valid
Definition: ProcStats.h:62
char buf[500]
Definition: ProcStats.h:61
double vsize
Definition: ProcStats.h:33
bool fetch(procInfo &fill_me)
Definition: ProcStats.cpp:273
double pageSize() const
Definition: ProcStats.h:43
procInfo()
Definition: ProcStats.h:14