REST-for-Physics  v2.3
Rare Event Searches ToolKit for Physics
TRestBenchMarkProcess.h
1 /*************************************************************************
2  * This file is part of the REST software framework. *
3  * *
4  * Copyright (C) 2016 GIFNA/TREX (University of Zaragoza) *
5  * For more information see http://gifna.unizar.es/trex *
6  * *
7  * REST is free software: you can redistribute it and/or modify *
8  * it under the terms of the GNU General Public License as published by *
9  * the Free Software Foundation, either version 3 of the License, or *
10  * (at your option) any later version. *
11  * *
12  * REST is distributed in the hope that it will be useful, *
13  * but WITHOUT ANY WARRANTY; without even the implied warranty of *
14  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
15  * GNU General Public License for more details. *
16  * *
17  * You should have a copy of the GNU General Public License along with *
18  * REST in $REST_PATH/LICENSE. *
19  * If not, see http://www.gnu.org/licenses/. *
20  * For the list of contributors see $REST_PATH/CREDITS. *
21  *************************************************************************/
22 
23 #ifndef RestProcess_TRestBenchMarkProcess
24 #define RestProcess_TRestBenchMarkProcess
25 
26 #include <TH1D.h>
27 
28 #include "TRestEventProcess.h"
29 
32  private:
33  TRestEvent* fEvent;
34 
35  int fCPUNumber;
36  int fMemNumber; // in kB
37  pid_t fPid;
38 
39  double fRefreshRate; // in Hz
40 
41  static std::thread* fMonitorThread;
42  static int fMonitorFlag;
43  static float fCPUUsageInPct;
44  static float fMemUsageInMB;
45  static float fReadingInMBs;
46  static float fProcessSpeedInHz;
47  static int fLastEventNumber;
48  static ULong64_t fStartTime;
49 
50  void Initialize() override;
51 
52  void SysMonitorFunc(int pid, double refreshRate = 1);
53 
54  protected:
55  public:
56  RESTValue GetInputEvent() const override { return fEvent; }
57  RESTValue GetOutputEvent() const override { return fEvent; }
58 
59  void InitProcess() override;
60  TRestEvent* ProcessEvent(TRestEvent* inputEvent) override;
61  void EndProcess() override;
62 
63  void PrintMetadata() override;
64 
65  // Constructor
67  // Destructor
69 
70  const char* GetProcessName() const override { return "BenchMarkProcess"; }
71 
72  ClassDefOverride(TRestBenchMarkProcess, 1);
73 };
74 #endif
A system performance monitor process for event flow rate, reading speed, cpu stress,...
static float fCPUUsageInPct
//0: return, 1: run
RESTValue GetOutputEvent() const override
Get pointer to output event. Must be implemented in the derived class.
TRestEvent * ProcessEvent(TRestEvent *inputEvent) override
Process one event.
void InitProcess() override
To be executed at the beginning of the run (outside event loop)
void PrintMetadata() override
Implemented it in the derived metadata class to print out specific metadata information.
void Initialize() override
Making default settings.
void EndProcess() override
To be executed at the end of the run (outside event loop)
RESTValue GetInputEvent() const override
Get pointer to input event. Must be implemented in the derived class.
A base class for any REST event process.
A base class for any REST event.
Definition: TRestEvent.h:38