24 #include <sys/types.h>
33 #include <boost/filesystem.hpp>
43 {
"VmPeak:", VirtualMemory::VMPEAK},
44 {
"VmSize:", VirtualMemory::VMSIZE},
45 {
"VmHWM:", VirtualMemory::VMHWM},
46 {
"VmRSS:", VirtualMemory::VMRSS},
47 {
"VmStk:", VirtualMemory::VMSTK},
48 {
"VmData:", VirtualMemory::VMDATA},
49 {
"VmExe:", VirtualMemory::VMEXE},
50 {
"VmLck:", VirtualMemory::VMLCK},
51 {
"VmPin:", VirtualMemory::VMPIN},
52 {
"VmLib:", VirtualMemory::VMLIB},
53 {
"VmPTE:", VirtualMemory::VMPTE},
54 {
"VmPMD:", VirtualMemory::VMPMD},
55 {
"VmSwap:", VirtualMemory::VMSWAP}
75 "Minimum peak virtual memory size");
78 "Maximum peak virtual memory size");
81 "Average peak virtual memory size");
85 "Minimum virtual memory size");
88 "Maximum virtual memory size");
91 "Average virtual memory size");
95 "Minimum peak resident set size");
98 "Maximum peak resident set size");
101 "Average peak resident set size");
105 "Minimum resident set size");
108 "Maximum resident set size");
111 "Average resident set size");
115 "Minimum stack size");
118 "Maximum stack size");
121 "Average stack size");
123 if (
mode_m == std::ios::app )
128 std::string dateStr(simtimer.
date());
129 std::string timeStr(simtimer.
time());
131 std::stringstream ss;
132 ss <<
"Memory statistics '"
134 << dateStr <<
"" << timeStr;
146 static pid_t pid = getpid();
147 std::string fname =
"/proc/" + std::to_string(pid) +
"/status";
149 if ( !boost::filesystem::exists(fname) ) {
151 "File '" + fname +
"' doesn't exist.");
154 std::ifstream ifs(fname.c_str());
156 if ( !ifs.is_open() ) {
158 "Failed to open '" + fname +
"'.");
161 std::string token =
"";
162 while (ifs >> token) {
181 for (
unsigned int i = 0; i <
vmem_m.size(); ++i) {
182 vmMin[i] = vmMax[i] = vmAvg[i] =
vmem_m[i];
190 for (
auto& vm : vmAvg) {
207 this->
compute(vmMin, vmMax, vmAvg);
213 double pathLength = beam->
get_sPos();
void new_reduce(const T *input, T *output, int count, Op op, int root=0)
std::string getInputFn()
get opals input filename
static OpalData * getInstance()
void write(const PartBunchBase< double, 3 > *beam) override
void compute(vm_t &vmMin, vm_t &vmMax, vm_t &vmAvg)
std::vector< long double > vm_t
MemoryProfiler(const std::string &fname, bool restart)
std::map< std::string, int > procinfo_m
void addColumn(const std::string &name, const std::string &type, const std::string &unit, const std::string &desc, std::ios_base::fmtflags flags=std::ios_base::scientific, unsigned short precision=15)
void addColumnValue(const std::string &name, const T &val)
std::string toString(const T &val)
void addDefaultParameters()
void addDescription(const std::string &text, const std::string &content)
void writeHeader()
Write SDDS header.
std::ios_base::openmode mode_m
First write to the statistics output file.
void addInfo(const std::string &mode, const size_t &no_row_counts)
The base class for all OPAL exceptions.
std::string date() const
Return date.
std::string time() const
Return time.