profile.hpp 10 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287
  1. /*************************************************************************
  2. * Copyright (C) [2020] by Cambricon, Inc. All rights reserved
  3. *
  4. * Licensed under the Apache License, Version 2.0 (the "License");
  5. * you may not use this file except in compliance with the License.
  6. * You may obtain a copy of the License at
  7. *
  8. * http://www.apache.org/licenses/LICENSE-2.0
  9. *
  10. * The above copyright notice and this permission notice shall be included in
  11. * all copies or substantial portions of the Software.
  12. * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
  13. * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  14. * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
  15. * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
  16. * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
  17. * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
  18. * THE SOFTWARE.
  19. *************************************************************************/
  20. #ifndef CNSTREAM_FRAMEWORK_CORE_INCLUDE_PROFILER_PROFILE_HPP_
  21. #define CNSTREAM_FRAMEWORK_CORE_INCLUDE_PROFILER_PROFILE_HPP_
  22. #include <string>
  23. #include <utility>
  24. #include <vector>
  25. /*!
  26. * @file profile.hpp
  27. *
  28. * This file contains the declarations of the StreamProfile, ProcessProfile, ModuleProfile and PipelineProfile struct.
  29. */
  30. namespace cnstream {
  31. /*!
  32. * @struct StreamProfile
  33. *
  34. * @brief The StreamProfile is a structure describing the performance statistics of streams.
  35. */
  36. struct StreamProfile {
  37. std::string stream_name; /*!< The stream name. */
  38. uint64_t counter = 0; /*!< The frame counter, it is equal to ``completed`` plus ``dropped``. */
  39. uint64_t completed = 0; /*!< The completed frame counter. */
  40. int64_t dropped = 0; /*!< The dropped frame counter. */
  41. double latency = 0.0; /*!< The average latency. (unit:ms) */
  42. double maximum_latency = 0.0; /*!< The maximum latency. (unit:ms) */
  43. double minimum_latency = 0.0; /*!< The minimum latency. (unit:ms) */
  44. double fps = 0.0; /*!< The throughput. */
  45. /*!
  46. * @brief Constructs a StreamProfile object with default constructor.
  47. *
  48. * @return No return value.
  49. */
  50. StreamProfile() = default;
  51. /*!
  52. * @brief Constructs a StreamProfile object with the copy of the contents of another object.
  53. *
  54. * @param[in] it Another object used to initialize an object.
  55. *
  56. * @return No return value.
  57. */
  58. StreamProfile(const StreamProfile& it) = default;
  59. /*!
  60. * @brief Replaces the contents with a copy of the contents of another StreamProfile object.
  61. *
  62. * @param[in] it Another object used to initialize the current object.
  63. *
  64. * @return Returns a lvalue reference to the current instance.
  65. */
  66. StreamProfile& operator=(const StreamProfile& it) = default;
  67. /*!
  68. * @brief Constructs a StreamProfile object with the contents of another object using move semantics.
  69. *
  70. * @param[in] it Another object used to initialize an object.
  71. *
  72. * @return No return value.
  73. */
  74. inline StreamProfile(StreamProfile&& it) {
  75. *this = std::forward<StreamProfile>(it);
  76. }
  77. /*!
  78. * @brief Replaces the contents with those of another StreamProfile object using move semantics.
  79. *
  80. * @param[in] it Another object used to initialize the current object.
  81. *
  82. * @return Returns a lvalue reference to the current instance.
  83. */
  84. inline StreamProfile& operator=(StreamProfile&& it) {
  85. stream_name = std::move(it.stream_name);
  86. counter = it.counter;
  87. completed = it.completed;
  88. dropped = it.dropped;
  89. latency = it.latency;
  90. maximum_latency = it.maximum_latency;
  91. minimum_latency = it.minimum_latency;
  92. fps = it.fps;
  93. return *this;
  94. }
  95. }; // struct StreamProfile
  96. /*!
  97. * @struct ProcessProfile
  98. *
  99. * @brief The ProcessProfile is a structure describing the performance statistics of process.
  100. */
  101. struct ProcessProfile {
  102. std::string process_name; /*!< The process name. */
  103. uint64_t counter = 0; /*!< The frame counter, it is equal to completed plus dropped frames. */
  104. uint64_t completed = 0; /*!< The completed frame counter. */
  105. int64_t dropped = 0; /*!< The dropped frame counter. */
  106. int64_t ongoing = 0; /*!< The number of frame being processed. */
  107. double latency = 0.0; /*!< The average latency. (unit:ms) */
  108. double maximum_latency = 0.0; /*!< The maximum latency. (unit:ms) */
  109. double minimum_latency = 0.0; /*!< The minimum latency. (unit:ms) */
  110. double fps = 0.0; /*!< The throughput. */
  111. std::vector<StreamProfile> stream_profiles; /*!< The stream profiles. */
  112. /*!
  113. * @brief Constructs a ProcessProfile object with default constructor.
  114. *
  115. * @return No return value.
  116. */
  117. ProcessProfile() = default;
  118. /*!
  119. * @brief Constructs a ProcessProfile object with the copy of the contents of another object.
  120. *
  121. * @param[in] it Another object used to initialize an object.
  122. *
  123. * @return No return value.
  124. */
  125. ProcessProfile(const ProcessProfile& it) = default;
  126. /*!
  127. * @brief Replaces the contents with a copy of the contents of another ProcessProfile object.
  128. *
  129. * @param[in] it Another object used to initialize the current object.
  130. *
  131. * @return Returns a lvalue reference to the current instance.
  132. */
  133. ProcessProfile& operator=(const ProcessProfile& it) = default;
  134. /*!
  135. * @brief Constructs a ProcessProfile object with the contents of another object using move semantics.
  136. *
  137. * @param[in] it Another object used to initialize an object.
  138. *
  139. * @return No return value.
  140. */
  141. inline ProcessProfile(ProcessProfile&& it) {
  142. *this = std::forward<ProcessProfile>(it);
  143. }
  144. /*!
  145. * @brief Replaces the contents with those of another ProcessProfile object using move semantics.
  146. *
  147. * @param[in] it Another object used to initialize the current object.
  148. *
  149. * @return Returns a lvalue reference to the current instance.
  150. */
  151. inline ProcessProfile& operator=(ProcessProfile&& it) {
  152. process_name = std::move(it.process_name);
  153. stream_profiles = std::move(it.stream_profiles);
  154. counter = it.counter;
  155. completed = it.completed;
  156. ongoing = it.ongoing;
  157. dropped = it.dropped;
  158. latency = it.latency;
  159. maximum_latency = it.maximum_latency;
  160. minimum_latency = it.minimum_latency;
  161. fps = it.fps;
  162. return *this;
  163. }
  164. }; // struct ProcessProfile
  165. /*!
  166. * @struct ModuleProfile
  167. *
  168. * @brief The ModuleProfile is a structure describing the performance statistics of module.
  169. */
  170. struct ModuleProfile {
  171. std::string module_name; /*!< The module name. */
  172. std::vector<ProcessProfile> process_profiles; /*!< The process profiles. */
  173. /*!
  174. * @brief Constructs a ModuleProfile object with default constructor.
  175. *
  176. * @return No return value.
  177. */
  178. ModuleProfile() = default;
  179. /*!
  180. * @brief Constructs a ModuleProfile object with the copy of the contents of another object.
  181. *
  182. * @param[in] it Another object used to initialize an object.
  183. *
  184. * @return No return value.
  185. */
  186. ModuleProfile(const ModuleProfile& it) = default;
  187. /*!
  188. * @brief Replaces the contents with a copy of the contents of another ModuleProfile object.
  189. *
  190. * @param[in] it Another object used to initialize the current object.
  191. *
  192. * @return Returns a lvalue reference to the current instance.
  193. */
  194. ModuleProfile& operator=(const ModuleProfile& it) = default;
  195. /*!
  196. * @brief Constructs a ModuleProfile object with the contents of another object using move semantics.
  197. *
  198. * @param[in] it Another object used to initialize an object.
  199. *
  200. * @return No return value.
  201. */
  202. inline ModuleProfile(ModuleProfile&& it) {
  203. *this = std::forward<ModuleProfile>(it);
  204. }
  205. /*!
  206. * @brief Replaces the contents with those of another ModuleProfile object using move semantics.
  207. *
  208. * @param[in] it Another object used to initialize the current object.
  209. *
  210. * @return Returns a lvalue reference to the current instance.
  211. */
  212. inline ModuleProfile& operator=(ModuleProfile&& it) {
  213. module_name = std::move(it.module_name);
  214. process_profiles = std::move(it.process_profiles);
  215. return *this;
  216. }
  217. }; // struct ModuleProfile
  218. /*!
  219. * @struct PipelineProfile
  220. *
  221. * @brief The PipelineProfile is a structure describing the performance statistics of pipeline.
  222. */
  223. struct PipelineProfile {
  224. std::string pipeline_name; /*!< The pipeline name. */
  225. std::vector<ModuleProfile> module_profiles; /*!< The module profiles. */
  226. ProcessProfile overall_profile; /*!< The profile of the whole pipeline. */
  227. /*!
  228. * @brief Constructs a PipelineProfile object with default constructor.
  229. *
  230. * @return No return value.
  231. */
  232. PipelineProfile() = default;
  233. /*!
  234. * @brief Constructs a PipelineProfile object with the copy of the contents of another object.
  235. *
  236. * @param[in] it Another object used to initialize an object.
  237. *
  238. * @return No return value.
  239. */
  240. PipelineProfile(const PipelineProfile& it) = default;
  241. /*!
  242. * @brief Replaces the contents with a copy of the contents of another PipelineProfile object.
  243. *
  244. * @param[in] it Another object used to initialize the current object.
  245. *
  246. * @return Returns a lvalue reference to the current instance.
  247. */
  248. PipelineProfile& operator=(const PipelineProfile& it) = default;
  249. /*!
  250. * @brief Constructs a PipelineProfile object with the contents of another object using move semantics.
  251. *
  252. * @param[in] it Another object used to initialize an object.
  253. *
  254. * @return No return value.
  255. */
  256. inline PipelineProfile(PipelineProfile&& it) {
  257. *this = std::forward<PipelineProfile>(it);
  258. }
  259. /*!
  260. * @brief Replaces the contents with those of another PipelineProfile object using move semantics.
  261. *
  262. * @param[in] it Another object used to initialize the current object.
  263. *
  264. * @return Returns a lvalue reference to the current instance.
  265. */
  266. inline PipelineProfile& operator=(PipelineProfile&& it) {
  267. pipeline_name = std::move(it.pipeline_name);
  268. module_profiles = std::move(it.module_profiles);
  269. overall_profile = std::move(it.overall_profile);
  270. return *this;
  271. }
  272. }; // struct PipelineProfile
  273. } // namespace cnstream
  274. #endif // CNSTREAM_FRAMEWORK_CORE_INCLUDE_PROFILER_PROFILE_HPP_