All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
Public Member Functions | List of all members
ana::ProfilerSupport Class Reference

Support for the –prof commandline option. More...

Public Member Functions

 ~ProfilerSupport ()
 

Detailed Description

Support for the –prof commandline option.

Definition at line 13 of file ProfilerSupport.cxx.

Constructor & Destructor Documentation

ana::ProfilerSupport::~ProfilerSupport ( )
inline

Definition at line 16 of file ProfilerSupport.cxx.

17  {
18  if(getenv("CPUPROFILE")){
19  char tmp[] = "/tmp/XXXXXX.pdf";
20  mkstemps(tmp, 4);
21 
22  const char* pd = getenv("GPERFTOOLS_DIR");
23  if(!pd){
24  std::cout << "Couldn't find pprof executable" << std::endl;
25  return;
26  }
27  const std::string perfdir = pd;
28 
29  const std::string pprof = perfdir + "/bin/pprof";
30 
31  // pprof needs both of these set
32  setenv("PATH", (perfdir+"/bin/:"+std::string(getenv("PATH"))).c_str(), 1);
33  setenv("LD_LIBRARY_PATH", (perfdir+"/lib/:"+std::string(getenv("LD_LIBRARY_PATH"))).c_str(), 1);
34 
35  std::cout << "Creating profile. This can take some time..." << std::endl;
36  const std::string cmd1 = pprof + " --pdf `which root.exe` " + std::string(getenv("CPUPROFILE")) + " > " + tmp;
37  std::cout << cmd1 << std::endl;
38  const int ret = system(cmd1.c_str());
39  if(ret != 0) return;
40 
41  std::cout << "Displaying profile..." << std::endl;
42  const std::string cmd2 = "evince "+std::string(tmp);
43  std::cout << cmd2 << std::endl;
44  system(cmd2.c_str());
45  }
46  }
BEGIN_PROLOG could also be cout

The documentation for this class was generated from the following file: