FairRoot
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
Read_Memory_File.C
Go to the documentation of this file.
1 /********************************************************************************
2  * Copyright (C) 2014 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH *
3  * *
4  * This software is distributed under the terms of the *
5  * GNU Lesser General Public Licence (LGPL) version 3, *
6  * copied verbatim in the file "LICENSE" *
7  ********************************************************************************/
8 #include "Riostream.h"
9 void Read_Memory_File(TString inputFile, Int_t Interval)
10 {
11  // Read data from the memeory_consumption_<pid>.txt file
12  // and create a root file with an ntuple.
13  // Author: Florian Uhlig
14 
15  // This file has one colum with the time and 10 colums with the data
16  // The time is the real time which has to be converted into the time
17  // difference between the actual and the first measurement.
18  // To make things simple for the begining the time interval is given
19  // as parameter and all new measurements have time=#measurement*Interval
20 
21  ifstream in;
22  in.open(inputFile.Data());
23 
24  Int_t vmPeak, vmSize, vmLck, vmHWM, vmRSS, vmData, vmStk, vmExe, vmLib, vmPTE;
25  Int_t time, timeZero, filesize;
26  Float_t cpu;
27  TString dummy[14];
28  Int_t nlines = 0;
29  Bool_t firstTime = kTRUE;
30 
31  TString outputFile(inputFile);
32  outputFile.ReplaceAll(".txt", ".root");
33  TFile *f = TFile::Open(outputFile, "RECREATE");
34  TNtuple *ntuple = new TNtuple("ntuple",
35  "data from ascii file",
36  "time:vmPeak:vmSize:vmLck:vmHWM:vmRSS:vmData:vmStk:vmExe:vmLib:vmPTE:filesize:cpu");
37 
38  // Read and skip the first colum which contains only the header
39  in >> dummy[0] >> dummy[1] >> dummy[2] >> dummy[3] >> dummy[4] >> dummy[5] >> dummy[6] >> dummy[7] >> dummy[8]
40  >> dummy[9] >> dummy[10] >> dummy[11] >> dummy[12] >> dummy[13];
41 
42  while (1) {
43  in >> dummy[0] >> time >> vmPeak >> dummy[1] >> vmSize >> dummy[2] >> vmLck >> dummy[3] >> vmHWM >> dummy[4]
44  >> vmRSS >> dummy[5] >> vmData >> dummy[6] >> vmStk >> dummy[7] >> vmExe >> dummy[8] >> vmLib >> dummy[9]
45  >> vmPTE >> dummy[10] >> filesize >> cpu;
46 
47  if (firstTime) {
48  timeZero = time;
49  firstTime = kFALSE;
50  }
51  time -= timeZero;
52  // filesize in MB
53  filesize /= 1024;
54  // time=nlines*Interval;
55  if (!in.good())
56  break;
57  ntuple->Fill(time, vmPeak, vmSize, vmLck, vmHWM, vmRSS, vmData, vmStk, vmExe, vmLib, vmPTE, filesize, cpu);
58  nlines++;
59  }
60  printf(" found %d measurements\n", nlines);
61 
62  in.close();
63 
64  f->Write();
65 }
void Read_Memory_File(TString inputFile, Int_t Interval)