HDK
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
networkStats.h
Go to the documentation of this file.
1 //
2 // Copyright 2025 Pixar
3 //
4 // Licensed under the terms set forth in the LICENSE.txt file available at
5 // https://openusd.org/license.
6 //
7 #ifndef PXR_EXEC_VDF_NETWORK_STATS_H
8 #define PXR_EXEC_VDF_NETWORK_STATS_H
9 
10 /// \file
11 
12 #include "pxr/pxr.h"
13 
14 #include "pxr/exec/vdf/api.h"
15 #include "pxr/base/tf/hash.h"
16 
17 #include <map>
18 #include <string>
19 
21 
22 class VdfNetwork;
23 
24 ////////////////////////////////////////////////////////////////////////////////
25 ///
26 /// \class VdfNetworkStats
27 ///
28 /// A VdfNetworkStats object represents some useful statistics about a network.
29 ///
31 {
32 public:
33 
34  // Struct used to keep track of statistics about a node type that we
35  // care about.
36  struct NodeTypeStats {
37  int count;
38  size_t memUsage;
39  };
40 
41 private:
42 
43  // Contains statistic information per node type.
44  typedef std::map<std::string, NodeTypeStats> _TypeStatsMap;
45  _TypeStatsMap _statsMap;
46 
47 public:
48 
49  /// Builds the statistics structures from the given \p network.
50  ///
51  VDF_API
52  VdfNetworkStats(const VdfNetwork &network);
53 
54 
55  /// Returns the length of the longest type name encountered.
56  ///
57  size_t GetMaxTypeNameLength() const { return _maxTypeNameLength; }
58 
59  /// Returns the max fan in.
60  ///
61  size_t GetMaxFanIn() const { return _maxFanIn; }
62 
63  /// Returns the node name with the max fan in.
64  ///
65  const std::string &GetMaxFanInNodeName() const {
66  return _maxFanInNodeName;
67  }
68 
69  /// Returns the max fan out.
70  ///
71  size_t GetMaxFanOut() const { return _maxFanOut; }
72 
73  /// Returns the node name with the max fan out.
74  ///
75  const std::string &GetMaxFanOutNodeName() const {
76  return _maxFanOutNodeName;
77  }
78 
79  /// Returns the count map.
80  ///
81  const _TypeStatsMap &GetStatsMap() const { return _statsMap; }
82 
83 private:
84 
85 
86  // The length of the longest encountered type name.
87  size_t _maxTypeNameLength;
88 
89  // The max number of inputs into a node and the node where it was
90  // encountered.
91  size_t _maxFanIn;
92  std::string _maxFanInNodeName;
93 
94  // The max number of outputs out of a ndoe and the node where it was
95  // encountered.
96  size_t _maxFanOut;
97  std::string _maxFanOutNodeName;
98 
99 };
100 
101 ////////////////////////////////////////////////////////////////////////////////
102 
104 
105 #endif
size_t GetMaxTypeNameLength() const
Definition: networkStats.h:57
size_t GetMaxFanIn() const
Definition: networkStats.h:61
#define PXR_NAMESPACE_OPEN_SCOPE
Definition: pxr.h:73
size_t GetMaxFanOut() const
Definition: networkStats.h:71
#define VDF_API
Definition: api.h:25
VDF_API VdfNetworkStats(const VdfNetwork &network)
#define PXR_NAMESPACE_CLOSE_SCOPE
Definition: pxr.h:74
const std::string & GetMaxFanOutNodeName() const
Definition: networkStats.h:75
const std::string & GetMaxFanInNodeName() const
Definition: networkStats.h:65
const _TypeStatsMap & GetStatsMap() const
Definition: networkStats.h:81