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)
 

Function Documentation

◆ doesDirectoryExist()

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

Definition at line 410 of file PerfMonMTUtils.h.

410  {
411  struct stat buffer;
412  return (stat(dir.c_str(), &buffer) == 0);
413 }

◆ get_mem_stats()

MemoryMap_t PMonMT::get_mem_stats ( )
inline

Definition at line 338 of file PerfMonMTUtils.h.

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

◆ get_process_cpu_time()

double PMonMT::get_process_cpu_time ( )
inline

Definition at line 320 of file PerfMonMTUtils.h.

320 { 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 308 of file PerfMonMTUtils.h.

308  {
309  // Get the thread specific CPU time
310  struct timespec ctime;
311  clock_gettime(CLOCK_THREAD_CPUTIME_ID, &ctime);
312 
313  // Return the measurement in ms
314  return static_cast<double>(ctime.tv_sec * 1.e3 + ctime.tv_nsec * 1.e-6);
315 }

◆ get_vmem()

double PMonMT::get_vmem ( )
inline

Definition at line 377 of file PerfMonMTUtils.h.

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

◆ get_wall_time()

double PMonMT::get_wall_time ( )
inline

Definition at line 325 of file PerfMonMTUtils.h.

325  {
326  return static_cast<double>(std::chrono::system_clock::now().time_since_epoch() / std::chrono::milliseconds(1));
327 }
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:122
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:21
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