Heavy ion Analysis Libriares
Loading...
Searching...
No Matches
DbgTask.cxx
1/*
2 * DbgTask.cxx
3 *
4 * Created on: 20 lut 2024
5 * Author: Daniel Wielanek
6 * E-mail: daniel.wielanek@gmail.com
7 * Warsaw University of Technology, Faculty of Physics
8 */
9#include "DbgTask.h"
10
11#include <TSystem.h>
12
13#include <iostream>
14
15namespace HalDbg {
16 void Task::SetLogFile(TString name) { fOutName = name; }
17
18 Task::EInitFlag Task::Init() {
19 if (fOutName.Length() > 0) {
20 fUseLog = kTRUE;
21 fOutLog.open(fOutName);
22 }
23 gSystem->GetProcInfo(&fProcInfo);
24 fPrevTime = fProcInfo.fCpuUser;
25 fTimer.Start();
26 if (fModulo < 0) fModulo = 1;
27 return Task::EInitFlag::kSUCCESS;
28 }
29
30 void Task::Exec(Option_t* /*option*/) {
31 if (fCounter % fModulo == 0) {
32 gSystem->GetProcInfo(&fProcInfo);
33 Double_t RamKB = fProcInfo.fMemResident;
34 Double_t dTime = fProcInfo.fCpuUser - fPrevTime;
35 fPrevTime = fProcInfo.fCpuUser;
36 TString info = Form("Event %8d Res Mem: %5d(MB) DUserCPU: %3.4f(s)", fCounter, int(RamKB / 1000.0), dTime);
37 if (fUseLog) {
38 fOutLog << info << std::endl;
39 } else {
40 std::cout << info << std::endl;
41 }
42 }
43 fCounter++;
44 }
45
47 fTimer.Stop();
48 if (fUseLog) {
49 fOutLog << "Timer report" << std::endl;
50 fOutLog << "CPU TIME: " << fTimer.CpuTime() << std::endl;
51 fOutLog << "Events processed: " << fCounter << std::endl;
52 fOutLog.close();
53 } else {
54 std::cout << "Timer report" << std::endl;
55 std::cout << "CPU TIME: " << fTimer.CpuTime() << std::endl;
56 std::cout << "Events processed: " << fCounter << std::endl;
57 }
58 }
59} // namespace HalDbg
virtual void FinishTask()
Definition DbgTask.cxx:46
virtual EInitFlag Init()
Definition DbgTask.cxx:18