34#include <boost/filesystem.hpp>
59 columns_m.addColumn(
"t",
"double",
"ns",
"Time");
61 columns_m.addColumn(
"s",
"double",
"m",
"Path length");
110 if (
mode_m == std::ios::app)
115 std::string dateStr(simtimer.
date());
116 std::string timeStr(simtimer.
time());
118 std::stringstream ss;
131 static pid_t pid = getpid();
132 std::string fname =
"/proc/" + std::to_string(pid) +
"/status";
134 if (!boost::filesystem::exists(fname)) {
135 throw OpalException(
"MemoryProfiler::update()",
"File '" + fname +
"' doesn't exist.");
138 std::ifstream ifs(fname.c_str());
140 if (!ifs.is_open()) {
141 throw OpalException(
"MemoryProfiler::update()",
"Failed to open '" + fname +
"'.");
145 while (ifs >> token) {
158 if (ippl::Comm->size() == 1) {
159 for (
unsigned int i = 0; i <
vmem_m.size(); ++i) {
160 vmMin[i] = vmMax[i] = vmAvg[i] =
vmem_m[i];
166 reduce(
vmem_m.data(), vmAvg.data(),
vmem_m.size(), std::plus<double>());
168 double inodes = 1.0 / double(ippl::Comm->size());
169 for (
auto& vm : vmAvg) {
175 reduce(
vmem_m.data(), vmMin.data(),
vmem_m.size(), std::less<double>());
176 reduce(
vmem_m.data(), vmMax.data(),
vmem_m.size(), std::greater<double>());
186 this->
compute(vmMin, vmMax, vmAvg);
188 if (ippl::Comm->rank() != 0) {
192 double pathLength = beam->
get_sPos();
201 columns_m.addColumnValue(
"s", pathLength);
PartBunch< PLayout_t< double, 3 >, double, 3 > PartBunch_t
std::string getInputFn()
get opals input filename
static OpalData * getInstance()
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 write(const PartBunch_t *beam) override
SDDSWriter(const std::string &fname, bool restart)
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 time() const
Return time.
std::string date() const
Return date.