My Project
TimingRecorderHydra.h
1 // Copyright 2023 DreamWorks Animation LLC
2 // SPDX-License-Identifier: Apache-2.0
3 
4 #pragma once
5 
6 #include <scene_rdl2/common/rec_time/RecTime.h>
7 #include <scene_rdl2/common/grid_util/Parser.h>
8 
9 #include <array>
10 #include <unordered_map>
11 
12 namespace mcrt_dataio {
13 
15 //
16 // The resolve action timing info with related messageHandler timing
17 //
18 {
19 public:
20  static constexpr size_t sMessageHandlerTotal = 4;
21 
22  ResolveInfo()
23  : mGetStart(0.0f)
24  , mGetEnd(0.0f)
25  , mRecvImgSenderMachineId(0)
26  {}
27  ResolveInfo(const std::string& name,
28  float start,
29  float end,
30  const std::array<float, sMessageHandlerTotal>& messageHandler,
31  int recvImgSenderMachineId)
32  : mName(name)
33  , mGetStart(start)
34  , mGetEnd(end)
35  , mMessageHandler{messageHandler}
36  , mRecvImgSenderMachineId(recvImgSenderMachineId)
37  {}
38 
39  const std::string& getName() const { return mName; }
40 
41  float getStart() const { return mGetStart; }
42  float getEnd() const { return mGetEnd; }
43 
44  const std::array<float, sMessageHandlerTotal>& getMessageHandler() const { return mMessageHandler; }
45  int getRecvImgSenderMachineId() const { return mRecvImgSenderMachineId; }
46 
47  float getDelta() const { return mGetEnd - mGetStart; }
48  std::string showSenderMachineId() const;
49 
50 private:
51  std::string mName;
52 
53  float mGetStart; // pixel data get action start timing
54  float mGetEnd; // pixel data get action finish timing
55 
56  std::array<float, sMessageHandlerTotal> mMessageHandler;
57  int mRecvImgSenderMachineId;
58 };
59 
61 //
62 // Timing recording operation designed for hydra deligate client
63 //
64 {
65 public:
66  using Arg = scene_rdl2::grid_util::Arg;
67  using Parser = scene_rdl2::grid_util::Parser;
68  using ResolveInfoShPtr = std::shared_ptr<ResolveInfo>;
69 
71 
72  //------------------------------
73 
74  void setInitArrasEnd(float sec);
75  std::string showInitArras() const;
76 
77  float getInitArrasEnd() const { return mInitArras; }
78 
79  //------------------------------
80 
81  void initGlobalBaseTime();
82  uint64_t getGlobalBaseTimeFromEpoch() const { return mGlobalBaseTimeFromEpoch; }
83 
84  void setConnect(size_t execPosId);
85  std::string showConnect() const;
86 
87  size_t getConnectTotal() const { return sConnectTotal; }
88  float getConnect(size_t execPosId) const;
89  std::string getConnectDescription(size_t execPosId) const;
90 
91  //------------------------------
92 
93  void setEndUpdate(size_t execPosId);
94  void setSendMessageSize(size_t size) { mSendMessageSize = size; }
95  void afterSendMessage();
96  std::string showEndUpdate() const;
97 
98  size_t getEndUpdateTotal() const { return sEndUpdateTotal; }
99  float getEndUpdate(size_t execPosId) const;
100  std::string getEndUpdateDescription(size_t execPosId) const;
101 
102  //------------------------------
103 
104  void setMessageHandler(size_t execPosId);
105  void setReceivedImageSenderMachineId(int machineId);
106  std::string showMessageHandler() const;
107 
108  size_t getMessageHandlerTotal() const { return sMessageHandlerTotal; }
109  float getMessageHandler(size_t execPosId) const;
110  std::string getMessageHandlerDescription(size_t execPosId) const;
111 
112  //------------------------------
113 
114  void setResolveStart();
115  void setResolve(const std::string& name);
116  std::string showResolve() const;
117 
118  const ResolveInfoShPtr get1stResolveInfo() const;
119  std::string show1stImgSenderMachineId() const;
120 
121  //------------------------------
122 
123  std::string show() const;
124 
125  //------------------------------
126 
127  Parser& getParser() { return mParser; }
128 
129 private:
130 
131  float mInitArras; // sec from initArras start
132 
133  uint64_t mGlobalBaseTimeFromEpoch; // initArras start time
134  scene_rdl2::rec_time::RecTime mGlobalBaseTime;
135 
136  static constexpr size_t sConnectTotal = 6;
137  std::array<std::string, sConnectTotal> mConnectDescription;
138  std::array<float, sConnectTotal> mConnect; // sec from initArras start
139 
140  static constexpr size_t sEndUpdateTotal = 4;
141  std::array<std::string, sEndUpdateTotal> mEndUpdateDescription;
142  std::array<float, sEndUpdateTotal> mEndUpdate; // sec from initArras start
143  size_t mSendMessageSize;
144 
145  static constexpr size_t sMessageHandlerTotal = ResolveInfo::sMessageHandlerTotal;
146  std::array<std::string, sMessageHandlerTotal> mMessageHandlerDescription;
147  std::array<float, sMessageHandlerTotal> mMessageHandler; // sec from initArras start
148  int mRecvImgSenderMachineId;
149 
150  float mResolveStart;
151  std::unordered_map<std::string, ResolveInfoShPtr> m1stResolve; // very 1st resolve action
152  std::unordered_map<std::string, ResolveInfoShPtr> mResolve; // non-1st resolve action (overwrite)
153 
154  Parser mParser;
155 
156  //------------------------------
157 
158  int maxSecStrLen(size_t execPosTotal,
159  const std::function<float(size_t execPosId)> &calcSecCallBack) const;
160 
161  std::string showMessageHandler(const std::array<float, sMessageHandlerTotal> &messageHandler,
162  int recvImgSenderMachineId) const;
163 
164  void parserConfigure();
165 };
166 
167 } // namespace mcrt_dataio
Definition: ClientReceiverConsoleDriver.cc:9
Definition: TimingRecorderHydra.h:14
Definition: TimingRecorderHydra.h:60