OLD | NEW |
(Empty) | |
| 1 //===- subzero/src/IceTimerTree.h - Pass timer defs -------------*- C++ -*-===// |
| 2 // |
| 3 // The Subzero Code Generator |
| 4 // |
| 5 // This file is distributed under the University of Illinois Open Source |
| 6 // License. See LICENSE.TXT for details. |
| 7 // |
| 8 //===----------------------------------------------------------------------===// |
| 9 // |
| 10 // This file declares the TimerTree class, which allows flat and |
| 11 // cumulative execution time collection of call chains. |
| 12 // |
| 13 //===----------------------------------------------------------------------===// |
| 14 |
| 15 #ifndef SUBZERO_SRC_ICETIMERTREE_H |
| 16 #define SUBZERO_SRC_ICETIMERTREE_H |
| 17 |
| 18 namespace Ice { |
| 19 |
| 20 class TimerTreeNode; |
| 21 |
| 22 // Timer tree index type |
| 23 typedef std::vector<TimerTreeNode>::size_type TTindex; |
| 24 |
| 25 // TimerTreeNode represents an interior or leaf node in the call tree. |
| 26 // It contains a list of children, a pointer to its parent, and the |
| 27 // timer ID for the node. It also holds the cumulative time spent at |
| 28 // this node and below. The children are always at a higher index in |
| 29 // the TimerTreeNode::Nodes array, and the parent is always at a lower |
| 30 // index. |
| 31 class TimerTreeNode { |
| 32 public: |
| 33 TimerTreeNode() : Parent(0), Interior(0), Time(0) {} |
| 34 std::vector<TTindex> Children; // indexed by TimerIdT |
| 35 TTindex Parent; |
| 36 TimerIdT Interior; |
| 37 double Time; |
| 38 }; |
| 39 |
| 40 class TimerStack { |
| 41 TimerStack(const TimerStack &) LLVM_DELETED_FUNCTION; |
| 42 TimerStack &operator=(const TimerStack &) LLVM_DELETED_FUNCTION; |
| 43 |
| 44 public: |
| 45 TimerStack(const IceString &TopLevelName); |
| 46 static TimerIdT getTimerID(const IceString &Name); |
| 47 void push(TimerIdT ID); |
| 48 void pop(TimerIdT ID); |
| 49 void dump(Ostream &Str); |
| 50 |
| 51 private: |
| 52 void update(); |
| 53 static double timestamp() { |
| 54 // TODO: Implement in terms of std::chrono for C++11. |
| 55 return llvm::TimeRecord::getCurrentTime(false).getWallTime(); |
| 56 } |
| 57 const double FirstTimestamp; |
| 58 double LastTimestamp; |
| 59 uint64_t StateChangeCount; |
| 60 static std::vector<IceString> IDs; // indexed by TimerIdT |
| 61 std::vector<TimerTreeNode> Nodes; // indexed by TTindex |
| 62 std::vector<double> LeafTimes; // indexed by TimerIdT |
| 63 TTindex StackTop; |
| 64 }; |
| 65 |
| 66 } // end of namespace Ice |
| 67 |
| 68 #endif // SUBZERO_SRC_ICETIMERTREE_H |
OLD | NEW |