| # Gaudi Framework, version v21r7p1 |

Home |  | Generated: 15 Feb 2010

# ProcStats.h

Go to the documentation of this file.

    00001 // $Id: ProcStats.h,v 1.2 2004/06/08 13:40:07 mato Exp $
    00002 #ifndef GAUDIAUD_PROCSTATS_H
    00003 #define GAUDIAUD_PROCSTATS_H
    00004
    00005 // Class: ProcStats
    00006 // Description:  Keeps statistics on memory usage
    00007 // Author: Jim Kowalkowski (FNAL), modified by M. Shapiro (LBNL)
    00008
    00009 #include <string>
    00010 #include <vector>
    00011
    00012 struct procInfo
    00013 {
    00014   procInfo() : vsize(0), rss(0) {}
    00015   procInfo(double sz, double rss_sz): vsize(sz),rss(rss_sz) {}
    00016
    00017   bool operator==(const procInfo& p) const
    00018     { return vsize==p.vsize && rss==p.rss; }
    00019
    00020   // see proc(4) man pages for units and a description
    00021   double vsize;  // in MB (used to be in pages?)
    00022   double rss;    // in MB (used to be in pages?)
    00023 };
    00024
    00025 class ProcStats
    00026 {
    00027 public:
    00028   static ProcStats* instance();
    00029
    00030   bool fetch(procInfo& fill_me);
    00031   double pageSize() const { return pg_size; }
    00032
    00033 private:
    00034   ProcStats();
    00035   ~ProcStats();
    00036
    00037   struct cleanup
    00038   {
    00039     cleanup() { }
    00040     ~cleanup();
    00041   };
    00042
    00043   friend struct cleanup;
    00044
    00045   int fd;
    00046   double pg_size;
    00047   procInfo curr;
    00048   std::string fname;
    00049   char buf[500];
    00050   bool valid;
    00051
    00052   static ProcStats* inst;
    00053 };
    00054
    00055 #endif
    00056