Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2024-04-06 12:13:05

0001 #ifndef FWCore_Services_ProcInfoFetcher_h
0002 #define FWCore_Services_ProcInfoFetcher_h
0003 // -*- C++ -*-
0004 //
0005 // Package:     Services
0006 // Class  :     ProcInfoFetcher
0007 //
0008 /**\class ProcInfoFetcher ProcInfoFetcher.h FWCore/Services/interface/ProcInfoFetcher.h
0009 
0010  Description:Class used to fetch process information
0011 
0012  Usage:
0013     <usage>
0014 
0015 */
0016 //
0017 // Original Author:  Chris Jones
0018 //         Created:  Sun May  6 11:14:28 CDT 2012
0019 //
0020 
0021 // system include files
0022 
0023 // user include files
0024 
0025 // forward declarations
0026 namespace edm {
0027   namespace service {
0028     struct ProcInfo {
0029       ProcInfo() : vsize(), rss() {}
0030       ProcInfo(double sz, double rss_sz) : vsize(sz), rss(rss_sz) {}
0031 
0032       bool operator==(const ProcInfo& p) const { return vsize == p.vsize && rss == p.rss; }
0033 
0034       bool operator>(const ProcInfo& p) const { return vsize > p.vsize || rss > p.rss; }
0035 
0036       // see proc(4) man pages for units and a description
0037       double vsize;  // in MB (used to be in pages?)
0038       double rss;    // in MB (used to be in pages?)
0039     };
0040 
0041     class ProcInfoFetcher {
0042     public:
0043       ProcInfoFetcher();
0044       ~ProcInfoFetcher();
0045       ProcInfoFetcher(ProcInfoFetcher const&) = delete;
0046       ProcInfoFetcher& operator=(ProcInfoFetcher const&) = delete;
0047 
0048       ProcInfo fetch() const;
0049 
0050     private:
0051       double pg_size_;
0052       int fd_;
0053       mutable char buf_[500];
0054     };
0055   }  // namespace service
0056 }  // namespace edm
0057 #endif