]>
Commit | Line | Data |
---|---|---|
0e8bc704 | 1 | /************************************************************************** |
2 | * Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. * | |
3 | * * | |
4 | * Author: The ALICE Off-line Project. * | |
5 | * Contributors are mentioned in the code where appropriate. * | |
6 | * * | |
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 | **************************************************************************/ | |
15 | ||
16 | ||
17 | #include <Riostream.h> | |
18 | #include "AliLog.h" | |
19 | #include "TStopwatch.h" | |
20 | #include "TSystem.h" | |
21 | #include "TTree.h" | |
22 | ||
23 | #include "TTimeStamp.h" | |
24 | #include "AliSysInfo.h" | |
25 | ||
26 | ||
27 | ClassImp(AliSysInfo) | |
28 | ||
29 | AliSysInfo* AliSysInfo::fInstance=0; | |
30 | ||
31 | AliSysInfo::AliSysInfo(): | |
32 | TObject(), | |
33 | fSysWatch(0), | |
34 | fTimer(0) | |
35 | { | |
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 | |
39 | ||
40 | ||
41 | (*fSysWatch) <<"hname"<<"/C:" // hname - hostname | |
42 | <<"sname"<<"/C:" // stamp name | |
43 | <<"first"<<"/I:" // first stamp | |
44 | // | |
45 | <<"stampSec"<<"/I:" // time - time stamp in seconds | |
46 | <<"mi.fMemUsed"<<"/F:" // system info | |
47 | <<"mi.fSwapUsed"<<"/F:" // | |
48 | <<"cI.fUser"<<"/F:" // | |
49 | <<"cI.fSys"<<"/F:" // | |
50 | // | |
51 | <<"pI.fMemResident"<<"/F:" // process info | |
52 | <<"pI.fMemVirtual"<<"/F:" // | |
53 | <<"pI.fCpuUser"<<"/F:" // | |
54 | <<"pI.fCpuSys"<<"/F:" // | |
55 | // | |
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:" // | |
61 | // | |
62 | <<"pIOld.fMemResident"<<"/F:" // process info -previous | |
63 | <<"pIOld.fMemVirtual"<<"/F:" // | |
64 | <<"pIOld.fCpuUser"<<"/F:" // | |
65 | <<"pIOld.fCpuSys"<<"/F" // | |
66 | << endl; | |
67 | ||
68 | } | |
69 | ||
70 | ||
71 | ||
72 | ||
73 | AliSysInfo * AliSysInfo::Instance(){ | |
74 | // | |
75 | // | |
76 | // | |
77 | if (!fInstance){ | |
78 | fInstance = new AliSysInfo; | |
79 | } | |
80 | return fInstance; | |
81 | } | |
82 | ||
83 | ||
84 | void AliSysInfo::AddStamp(const char *stamp){ | |
85 | // | |
86 | // | |
87 | // | |
88 | Instance()->Print(stamp); | |
89 | } | |
90 | ||
91 | ||
92 | void AliSysInfo::Print(Option_t* option ) const{ | |
93 | // | |
94 | // | |
95 | // | |
96 | char sname[1000]; | |
97 | sprintf(sname,"n-%s",option); | |
98 | TTimeStamp stamp; | |
99 | CpuInfo_t cpuInfo; | |
100 | MemInfo_t memInfo; | |
101 | ProcInfo_t procInfo; | |
102 | gSystem->GetCpuInfo(&cpuInfo, 10); | |
103 | gSystem->GetMemInfo(&memInfo); | |
104 | gSystem->GetProcInfo(&procInfo); | |
105 | const char * hname = gSystem->HostName(); | |
106 | ||
107 | static Int_t entry=0; | |
108 | static Int_t first=stamp.GetSec(); | |
109 | // | |
110 | static TTimeStamp stampOld; | |
111 | static CpuInfo_t cpuInfoOld; | |
112 | static MemInfo_t memInfoOld; | |
113 | static ProcInfo_t procInfoOld; | |
114 | ||
115 | ||
116 | (*fSysWatch) << hname <<"\t" // hname - hostname | |
117 | << sname <<"\t" // stamp name | |
118 | << first <<"\t" // first stamp | |
119 | // | |
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" // | |
125 | // | |
126 | << procInfo.fMemResident<<"\t" // process info | |
127 | << procInfo.fMemVirtual<<"\t" // | |
128 | << procInfo.fCpuUser<<"\t" // | |
129 | << procInfo.fCpuSys<<"\t" // | |
130 | // | |
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" // | |
136 | // | |
137 | << procInfoOld.fMemResident<<"\t" // process info -previous | |
138 | << procInfoOld.fMemVirtual<<"\t" // | |
139 | << procInfoOld.fCpuUser<<"\t" // | |
140 | << procInfoOld.fCpuSys<<"\t" // | |
141 | << endl; | |
142 | stampOld = stamp; | |
143 | cpuInfoOld = cpuInfo; | |
144 | memInfoOld = memInfo; | |
145 | procInfoOld= procInfo; | |
146 | entry++; | |
147 | } | |
148 | ||
149 | ||
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"); | |
156 | return tree; | |
157 | } | |
158 |