Read_Memory_File.C 2.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061
  1. #include "Riostream.h"
  2. void Read_Memory_File(TString inputFile, Int_t Interval) {
  3. // Read data from the memeory_consumption_<pid>.txt file
  4. // and create a root file with an ntuple.
  5. //Author: Florian Uhlig
  6. // This file has one colum with the time and 10 colums with the data
  7. // The time is the real time which has to be converted into the time
  8. // difference between the actual and the first measurement.
  9. // To make things simple for the begining the time interval is given
  10. // as parameter and all new measurements have time=#measurement*Interval
  11. ifstream in;
  12. in.open(inputFile.Data());
  13. Int_t vmPeak,vmSize,vmLck,vmHWM,vmRSS,vmData,vmStk,vmExe,vmLib,vmPTE;
  14. Int_t time, timeZero, filesize;
  15. Float_t cpu;
  16. TString dummy[14];
  17. Int_t nlines = 0;
  18. Bool_t firstTime=kTRUE;
  19. TString outputFile(inputFile);
  20. outputFile.ReplaceAll(".txt",".root");
  21. TFile *f = new TFile(outputFile,"RECREATE");
  22. TNtuple *ntuple = new TNtuple("ntuple","data from ascii file",
  23. "time:vmPeak:vmSize:vmLck:vmHWM:vmRSS:vmData:vmStk:vmExe:vmLib:vmPTE:filesize:cpu");
  24. // Read and skip the first colum which contains only the header
  25. in >> dummy[0] >> dummy[1] >> dummy[2] >> dummy[3] >> dummy[4]
  26. >> dummy[5] >> dummy[6] >> dummy[7] >> dummy[8] >> dummy[9]
  27. >> dummy[10] >> dummy[11] >> dummy[12]
  28. >> dummy[13];
  29. while (1) {
  30. in >> dummy[0] >> time >> vmPeak >> dummy[1] >> vmSize >> dummy[2]
  31. >> vmLck >> dummy[3] >> vmHWM >> dummy[4] >> vmRSS >> dummy[5]
  32. >> vmData >> dummy[6] >> vmStk >> dummy[7] >> vmExe >> dummy[8]
  33. >> vmLib >> dummy[9] >> vmPTE >> dummy[10] >> filesize
  34. >> cpu;
  35. if (firstTime) {
  36. timeZero=time;
  37. firstTime=kFALSE;
  38. }
  39. time-=timeZero;
  40. // filesize in MB
  41. filesize/=1024;
  42. // time=nlines*Interval;
  43. if (!in.good()) break;
  44. ntuple->Fill(time,vmPeak,vmSize,vmLck,vmHWM,vmRSS,vmData,vmStk,vmExe,vmLib,vmPTE,filesize,cpu);
  45. nlines++;
  46. }
  47. printf(" found %d measurements\n",nlines);
  48. in.close();
  49. f->Write();
  50. }