ATLAS Offline Software
Classes | Functions
PMonMT Namespace Reference

Classes

struct  ComponentData
 
struct  ComponentMeasurement
 
struct  EventLevelData
 
struct  SnapshotData
 
struct  SnapshotMeasurement
 
struct  StepComp
 

Functions

double get_thread_cpu_time ()
 
double get_process_cpu_time ()
 
double get_wall_time ()
 
MemoryMap_t get_mem_stats ()
 
double get_vmem ()
 
bool doesDirectoryExist (const std::string &dir)
 
double get_malloc_kb ATLAS_NOT_THREAD_SAFE ()
 
const char * symb2lib (const char *symbol, const char *failstr)
 

Function Documentation

◆ ATLAS_NOT_THREAD_SAFE()

double get_malloc_kb PMonMT::ATLAS_NOT_THREAD_SAFE ( )

◆ doesDirectoryExist()

bool PMonMT::doesDirectoryExist ( const std::string &  dir)
inline

Definition at line 416 of file PerfMonMTUtils.h.

416  {
417  struct stat buffer;
418  return (stat(dir.c_str(), &buffer) == 0);
419 }

◆ get_mem_stats()

MemoryMap_t PMonMT::get_mem_stats ( )
inline

Definition at line 344 of file PerfMonMTUtils.h.

344  {
345  // Result object
347 
348  // Zero initialize
349  result["vmem"] = result["rss"] = result["pss"] = result["swap"] = 0;
350 
351  // This is the input where we read the stats from
352  static const std::string fileName = "/proc/self/smaps";
353  std::ifstream smaps_file{fileName};
354 
355  std::string line{}, key{}, value{};
356 
357  // Loop over the file
358  while (smaps_file) {
359  // Read interesting key value pairs
360  smaps_file >> key >> value;
361  smaps_file.ignore(std::numeric_limits<std::streamsize>::max(),'\n');
362 
363  if(smaps_file) {
364  if (key == "Size:") {
365  result["vmem"] += std::stol(value);
366  }
367  if (key == "Rss:") {
368  result["rss"] += std::stol(value);
369  }
370  if (key == "Pss:") {
371  result["pss"] += std::stol(value);
372  }
373  if (key == "Swap:") {
374  result["swap"] += std::stol(value);
375  }
376  }
377  }
378 
379  return result;
380 }

◆ get_process_cpu_time()

double PMonMT::get_process_cpu_time ( )
inline

Definition at line 326 of file PerfMonMTUtils.h.

326 { return static_cast<double>(std::clock() * (1.e3 / CLOCKS_PER_SEC)); }

◆ get_thread_cpu_time()

double PMonMT::get_thread_cpu_time ( )
inline

Definition at line 314 of file PerfMonMTUtils.h.

314  {
315  // Get the thread specific CPU time
316  struct timespec ctime;
317  clock_gettime(CLOCK_THREAD_CPUTIME_ID, &ctime);
318 
319  // Return the measurement in ms
320  return static_cast<double>(ctime.tv_sec * 1.e3 + ctime.tv_nsec * 1.e-6);
321 }

◆ get_vmem()

double PMonMT::get_vmem ( )
inline

Definition at line 383 of file PerfMonMTUtils.h.

383  {
384  // Result
385  double result = 0.;
386 
387  // This is where we read the stats from
388  static const std::string fileName = "/proc/self/statm";
389  std::ifstream statm_file{fileName};
390 
391  std::string vmem_in_pages{}, line{}; // vmem measured in pages
392 
393  // We simply get the first line
394  if (getline(statm_file, line)) {
395  std::stringstream ss{line};
396  ss >> vmem_in_pages; // The first number in this file is the vmem measured in pages
397  }
398 
399  static const double page_size = sysconf(_SC_PAGESIZE) / 1024.0; // page size in KB
400  result = std::stod(vmem_in_pages) * page_size;
401 
402  return result;
403 }

◆ get_wall_time()

double PMonMT::get_wall_time ( )
inline

Definition at line 331 of file PerfMonMTUtils.h.

331  {
332  return static_cast<double>(std::chrono::system_clock::now().time_since_epoch() / std::chrono::milliseconds(1));
333 }

◆ symb2lib()

const char * PMonMT::symb2lib ( const char *  symbol,
const char *  failstr = "unknown" 
)
inline

Definition at line 436 of file PerfMonMTUtils.h.

436  {
437  void * addr = dlsym(RTLD_DEFAULT,symbol);
438  if (!addr) return failstr;
439  Dl_info di;
440  if (!dladdr(addr, &di)) return failstr;
441  if (!di.dli_fname) return failstr;
442  return di.dli_fname;
443 }
checkFileSG.line
line
Definition: checkFileSG.py:75
get_generator_info.result
result
Definition: get_generator_info.py:21
max
#define max(a, b)
Definition: cfImp.cxx:41
PowhegControl_ttHplus_NLO.ss
ss
Definition: PowhegControl_ttHplus_NLO.py:83
athena.value
value
Definition: athena.py:124
python.handimod.now
now
Definition: handimod.py:675
createCoolChannelIdFile.buffer
buffer
Definition: createCoolChannelIdFile.py:12
FortranAlgorithmOptions.fileName
fileName
Definition: FortranAlgorithmOptions.py:13
PerfMon::clock_gettime
struct timespec clock_gettime()
Definition: PerfMonEventDict.h:18
beamspotman.stat
stat
Definition: beamspotman.py:266
beamspotman.dir
string dir
Definition: beamspotman.py:623
MemoryMap_t
std::map< std::string, int64_t > MemoryMap_t
Definition: PerfMonMTUtils.h:31
mapkey::key
key
Definition: TElectronEfficiencyCorrectionTool.cxx:37