1 /**************************************************************************
2 * Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. *
4 * Author: The ALICE Off-line Project. *
5 * Contributors are mentioned in the code where appropriate. *
7 * Permission to use, copy, modify and distribute this software and its *
8 * documentation strictly for non-commercial purposes is hereby granted *
9 * without fee, provided that the above copyright notice appears in all *
10 * copies and that both the copyright notice and this permission notice *
11 * appear in the supporting documentation. The authors make no claims *
12 * about the suitability of this software for any purpose. It is *
13 * provided "as is" without express or implied warranty. *
14 **************************************************************************/
17 #include <Riostream.h>
19 #include "TStopwatch.h"
23 #include "TTimeStamp.h"
24 #include "AliSysInfo.h"
29 AliSysInfo* AliSysInfo::fInstance=0;
31 AliSysInfo::AliSysInfo():
36 fTimer = new TStopwatch;
37 fSysWatch = new fstream("syswatch.log", ios_base::out|ios_base::trunc);
38 //hname/C:sname/C:sec/I:mI.fMemUsed/F:mI.fSwapUsed/F:pI.fMemResident/F:pI.fMemVirtual/F:cI.fUser/F:cI.fSys/F:cI.fCpuUser/F:pI.fCpuSys/F
41 (*fSysWatch) <<"hname"<<"/C:" // hname - hostname
42 <<"sname"<<"/C:" // stamp name
43 <<"first"<<"/I:" // first stamp
45 <<"stampSec"<<"/I:" // time - time stamp in seconds
46 <<"mi.fMemUsed"<<"/F:" // system info
47 <<"mi.fSwapUsed"<<"/F:" //
48 <<"cI.fUser"<<"/F:" //
51 <<"pI.fMemResident"<<"/F:" // process info
52 <<"pI.fMemVirtual"<<"/F:" //
53 <<"pI.fCpuUser"<<"/F:" //
54 <<"pI.fCpuSys"<<"/F:" //
56 <<"stampOldSec"<<"/I:" // time - time stamp in seconds
57 <<"miOld.fMemUsed"<<"/F:" // system info - previous
58 <<"miOld.fSwapUsed"<<"/F:" //
59 <<"cIOld.fUser"<<"/F:" //
60 <<"cIOld.fSys"<<"/F:" //
62 <<"pIOld.fMemResident"<<"/F:" // process info -previous
63 <<"pIOld.fMemVirtual"<<"/F:" //
64 <<"pIOld.fCpuUser"<<"/F:" //
65 <<"pIOld.fCpuSys"<<"/F" //
73 AliSysInfo * AliSysInfo::Instance(){
78 fInstance = new AliSysInfo;
84 void AliSysInfo::AddStamp(const char *stamp){
88 Instance()->Print(stamp);
92 void AliSysInfo::Print(Option_t* option ) const{
97 sprintf(sname,"n-%s",option);
102 gSystem->GetCpuInfo(&cpuInfo, 10);
103 gSystem->GetMemInfo(&memInfo);
104 gSystem->GetProcInfo(&procInfo);
105 const char * hname = gSystem->HostName();
107 static Int_t entry=0;
108 static Int_t first=stamp.GetSec();
110 static TTimeStamp stampOld;
111 static CpuInfo_t cpuInfoOld;
112 static MemInfo_t memInfoOld;
113 static ProcInfo_t procInfoOld;
116 (*fSysWatch) << hname <<"\t" // hname - hostname
117 << sname <<"\t" // stamp name
118 << first <<"\t" // first stamp
120 << stamp.GetSec()<<"\t" // time - time stamp in seconds
121 << memInfo.fMemUsed<<"\t" // system info
122 << memInfo.fSwapUsed<<"\t" //
123 << cpuInfo.fUser <<"\t" //
124 << cpuInfo.fSys <<"\t" //
126 << procInfo.fMemResident<<"\t" // process info
127 << procInfo.fMemVirtual<<"\t" //
128 << procInfo.fCpuUser<<"\t" //
129 << procInfo.fCpuSys<<"\t" //
131 << stampOld.GetSec()<<"\t" // time - time stamp in seconds
132 << memInfoOld.fMemUsed<<"\t" // system info - previous
133 << memInfoOld.fSwapUsed<<"\t" //
134 << cpuInfoOld.fUser <<"\t" //
135 << cpuInfoOld.fSys <<"\t" //
137 << procInfoOld.fMemResident<<"\t" // process info -previous
138 << procInfoOld.fMemVirtual<<"\t" //
139 << procInfoOld.fCpuUser<<"\t" //
140 << procInfoOld.fCpuSys<<"\t" //
143 cpuInfoOld = cpuInfo;
144 memInfoOld = memInfo;
145 procInfoOld= procInfo;
150 TTree * AliSysInfo::MakeTree(const char *lname){
151 // char * lname = "syswatch.log"
152 TTree * tree = new TTree;
153 tree->ReadFile(lname);
154 tree->SetAlias("deltaT","stampSec-stampOldSec");
155 tree->SetAlias("deltaVM","(pI.fMemVirtual-pIOld.fMemVirtual)*0.001");