ATLAS Offline Software
Loading...
Searching...
No Matches
AthMonBench.cxx
Go to the documentation of this file.
1/*
2 Copyright (C) 2002-2024 CERN for the benefit of the ATLAS collaboration
3*/
4
5#include "AthMonBench.h"
6#include <iostream>
7#include <limits>
8#include <string>
9#include <fstream>
10
11namespace{
12 template <long f>
13 long
14 multiply(long result){
15 static constexpr long maxval = std::numeric_limits<long>::max()/f;
16 if ((result>maxval) or (result<0)) return -1;
17 return result * f;
18 }
19}
20
23 long result = -1;
24 std::ifstream file("/proc/self/status");
25 const std::string search{"VmSize:"};
26 std::string line;
27 while(getline(file, line)) {
28 if (line.starts_with(search)) {
29 result = std::stol(line.substr(search.size()));
30 result = multiply<1024L>(result);
31 break;
32 }
33 }
34 return result;
35}
36
37std::ostream& operator << ( std::ostream& os, const AthMonBench& br) {
38 if (br.valid())
39 os << "deltaMem: "<<br.deltaMem_mb()<<" mb, deltaCPU: "<<br.deltaCPU_ms()<<" ms";
40 else
41 os <<" [no data]";
42 return os;
43}
std::ostream & operator<<(std::ostream &os, const AthMonBench &br)
long long TMem
Definition AthMonBench.h:52
static TMem currentVMem()
void search(TDirectory *td, const std::string &s, std::string cwd, node *n)
recursive directory search for TH1 and TH2 and TProfiles
Definition hcg.cxx:739
TFile * file