| # Gaudi Framework, version v21r11 |

Home |  | Generated: 30 Sep 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 #ifdef __ICC
    00019 // disable icc remark #1572: floating-point equality and inequality comparisons are unreliable
    00020 #pragma warning(push)
    00021 #pragma warning(disable:1572)
    00022 #endif
    00023
    00024     return vsize==p.vsize && rss==p.rss;
    00025
    00026 #ifdef __ICC
    00027 // re-enable icc remark #1572
    00028 #pragma warning(pop)
    00029 #endif
    00030   }
    00031
    00032   // see proc(4) man pages for units and a description
    00033   double vsize;  // in MB (used to be in pages?)
    00034   double rss;    // in MB (used to be in pages?)
    00035 };
    00036
    00037 class ProcStats
    00038 {
    00039 public:
    00040   static ProcStats* instance();
    00041
    00042   bool fetch(procInfo& fill_me);
    00043   double pageSize() const { return pg_size; }
    00044
    00045 private:
    00046   ProcStats();
    00047   ~ProcStats();
    00048
    00049   struct cleanup
    00050   {
    00051     cleanup() { }
    00052     ~cleanup();
    00053   };
    00054
    00055   friend struct cleanup;
    00056
    00057   int fd;
    00058   double pg_size;
    00059   procInfo curr;
    00060   std::string fname;
    00061   char buf[500];
    00062   bool valid;
    00063
    00064   static ProcStats* inst;
    00065 };
    00066
    00067 #endif
    00068