ATLAS Offline Software
Loading...
Searching...
No Matches
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 415 of file PerfMonMTUtils.h.

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

◆ get_mem_stats()

MemoryMap_t PMonMT::get_mem_stats ( )
inline

Definition at line 343 of file PerfMonMTUtils.h.

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

◆ get_process_cpu_time()

double PMonMT::get_process_cpu_time ( )
inline

Definition at line 325 of file PerfMonMTUtils.h.

325{ 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 313 of file PerfMonMTUtils.h.

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

◆ get_vmem()

double PMonMT::get_vmem ( )
inline

Definition at line 382 of file PerfMonMTUtils.h.

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

◆ get_wall_time()

double PMonMT::get_wall_time ( )
inline

Definition at line 330 of file PerfMonMTUtils.h.

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

◆ symb2lib()

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

Definition at line 435 of file PerfMonMTUtils.h.

435 {
436 void * addr = dlsym(RTLD_DEFAULT,symbol);
437 if (!addr) return failstr;
438 Dl_info di;
439 if (!dladdr(addr, &di)) return failstr;
440 if (!di.dli_fname) return failstr;
441 return di.dli_fname;
442}