VR-Forces Development_Version Class Documentation
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
profileNode.h
Go to the documentation of this file.
1 /*********************************************************************************
2 ** Copyright (c) 2014 MAK Technologies, Inc.
3 ** All rights reserved.
4 *********************************************************************************/
5 
10 
11 #pragma once
12 
13 #include "vrfutil/vrfutilDefines.h"
14 
15 #include "vrfutil/columnLogger.h"
16 
17 #include <tbb/tick_count.h>
18 #include <tbb/spin_mutex.h>
19 #include <tbb/spin_rw_mutex.h>
20 #include <tbb/atomic.h>
21 
22 #include <iosfwd>
23 
24 namespace makVrf
25 {
26  class DtProfileManager;
27 
28  typedef unsigned long long DtUInt64;
29 
32  {
34  double time;
35 
37  DtProfileStat();
38 
40  void reset();
41 
43  double instructionsPerSecond() const;
44 
46  DtProfileStat& operator+=(const DtProfileStat&);
47 
49  template <typename T>
50  DtProfileStat operator/(const T& val) const
51  {
52  DtProfileStat stat(*this);
53  stat.instructions /= val;
54  stat.time /= val;
55  return stat;
56  }
57  };
58 
61  {
63  static DtProfileTimestamp Now();
64 
67 
69  DtProfileStat operator-(const DtProfileTimestamp&) const;
70 
72  tbb::tick_count timestamp;
73  };
74 
78  {
79  public:
81  {
82  ENONE = 0,
83  EVIRTUAL = 1,
84  EINVISIBLE = 2,
85  ENODE = 3
86  };
87 
90  const char* name,
91  DtProfileManager* mgr,
92  DtProfileNode * parent,
93  Attributes attr);
94 
96  ~DtProfileNode();
97 
101  DtProfileNode* getChildNode(const char*, Attributes attr = ENONE);
102 
103  bool isVirtual() const { return ((myAttributes & EVIRTUAL) != 0); }
104  bool isInvisible() const { return ((myAttributes & EINVISIBLE) != 0); }
105 
107  DtProfileNode* parent() const { return myParent; }
109  DtProfileNode* sibling() const { return mySibling; }
111  DtProfileNode* child() const { return myChild; }
112 
114  void reset();
115 
117  const char* name() const { return myName; }
119  int totalCalls() const { return myTotalCalls; }
121  DtProfileStat totalTime() const { return myTotalTime; }
123  DtProfileStat timeLastFrame() const;
125  unsigned nestingLevel() const { return myNestingLevel; }
126 
127  void nextFrame();
128 
129  protected:
130  friend class DtProfileManager;
131 
133  DtProfileTimestamp call();
137  bool finish(const DtProfileTimestamp& start);
138 
140 
141  const char* myName;
142 
143 
144  typedef tbb::spin_mutex StatMutex;
148 
150  tbb::atomic<int> myTotalCalls;
151  tbb::atomic<int> myTotalCallsThisFrame;
152  //int myRecursionCounter; //! current recursion level
153 
154  typedef tbb::spin_rw_mutex Mutex;
155  mutable Mutex myMutex;
156 
163  unsigned myNestingLevel;
164 
166 
172  };
173 }

Document ID: Generated on Mon Jul 4 01:00:18 EDT 2016 from SVN revision 166489
Copyright © 2005-2015 VT MÄK. All Rights Reserved (www.mak.com)