-
Notifications
You must be signed in to change notification settings - Fork 41
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[WIP] Add memory measurements to interpreted PyROOT #95
Changes from 1 commit
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
///\file Memory measurement. | ||
|
||
#include <string> | ||
|
||
//running usr/bin/time to collect measurements in perffile | ||
std::string getMemoryStats(const std::string& dir, const std::string& filename, std::string& rootInvocation, const std::string& rootexe, const std::string& endInvoc); | ||
|
||
//getting Maximum resident set size form perffile and storing in peakSize | ||
int getMemoryMeasurement(std::string& perftutorial); | ||
|
||
//extracting filename from given path | ||
std::string getFileName(std::string& path); | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,4 @@ | ||
RB_ADD_LIBRARY(RBSupport | ||
ErrorHandling.cxx | ||
MemoryMeasurement.cxx | ||
) |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
///\file Contains utilities to measure memory usage. | ||
#include <iostream> | ||
#include <cstdlib> | ||
#include <string> | ||
#include <cstdlib> | ||
#include <fstream> | ||
#include <iostream> | ||
#include <unistd.h> | ||
#include <chrono> | ||
#include <stdlib.h> | ||
#include "rootbench/RBConfig.h" | ||
#include "rootbench/MemoryMeasurement.h" | ||
|
||
std::string getFileName(std::string path) { | ||
std::string base_fn = path.substr(path.find_last_of("/\\") + 1); | ||
return base_fn.substr(0, base_fn.find_last_of('.')); | ||
} | ||
|
||
std::string getMemoryStats(const std::string& dir, const std::string& filename, std::string& rootInvocation, const std::string& rootexe, const std::string& endInvoc) { | ||
std::string perffile=""; | ||
if (access("/usr/bin/time", X_OK) == 0) { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. We should not hardcode this path There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. alright! I will try to change it. |
||
std::string rootsys = RB::GetRootSys(); | ||
std::string thisroot = rootsys + "/bin/thisroot.sh"; | ||
perffile = getFileName(filename) + "_perfile.txt"; | ||
if (!filename.empty()) { | ||
std::string fullpath = rootsys + "/" + dir + filename; | ||
// FIXME: no source in /usr/dash | ||
// We are writing /usr/bin/time -v output in file to get maximum resident memory for the benchmark | ||
rootInvocation = "/usr/bin/time -v -o \"" + perffile + rootexe + fullpath + endInvoc; | ||
std::cout<<"helllloooooooooooooooooooo "<< rootInvocation <<" hellllllloooooooooooooo"<<std::endl; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Looks like debug printouts. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yes sorry, forgot to remove them. |
||
} | ||
else { | ||
rootInvocation = "/usr/bin/time -v -o \"" + perffile + "\" root.exe -l -q -b "; // for pyroot? | ||
} | ||
} | ||
else { | ||
std::cout << "Cannot find usr/bin/time" << std::endl; | ||
} | ||
return perffile; | ||
} | ||
// rootInvocation = "source \"" + thisroot + "\" && /usr/bin/time -v -o \"" + perffile + "\" root.exe -l -q -b -n -x \"" + fullpath + "\" -e return "; | ||
// rootInvocation = "source \"" + thisroot + "\" && /usr/bin/time -v -o \"" + perffile + "\" root.exe -l -q -b "; | ||
|
||
int getMemoryMeasurement(std::string& perftutorial) { | ||
int peakSize=0; | ||
std::string memorytutorial = "cat \"" + perftutorial + "\"| grep 'Maximum resident set size' | awk '{print $6}' > tmp_mem_file"; | ||
int res = std::system(memorytutorial.c_str()); | ||
(void) res; | ||
std::ifstream("tmp_mem_file") >> peakSize; | ||
return peakSize; | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Includes should be in reverse order, that is, less generic to more generic.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks! I will change the order.