Changeset 3c0d4cd for src/Common
- Timestamp:
- Mar 5, 2019, 2:17:45 PM (6 years ago)
- Branches:
- ADT, aaron-thesis, arm-eh, ast-experimental, cleanup-dtors, enum, forall-pointer-decay, jacob/cs343-translation, jenkins-sandbox, master, new-ast, new-ast-unique-expr, persistent-indexer, pthread-emulation, qualifiedEnum
- Children:
- c884f2d
- Parents:
- 79eaeb7
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
src/Common/Stats/Time.cc
r79eaeb7 r3c0d4cd 33 33 typedef std::chrono::time_point<std::chrono::high_resolution_clock> point_t; 34 34 std::chrono::duration<double> total; 35 std::chrono::duration<double> parent;36 35 37 36 point_t global_begin; 37 38 size_t prevl = 0; 39 size_t currl = 0; 38 40 39 41 template<typename T> … … 85 87 86 88 virtual void print(std::ostream & os) override { 89 if(currl > prevl) { 90 parents.push(last); 91 } else if(currl < prevl) { 92 parents.pop(); 93 } else { 94 last = end - begin; 95 } 96 87 97 assert(finished); 88 98 std::chrono::duration<double> diff = end - begin; 89 99 os << diff << " | "; 90 os << std::setw(7) << std::setprecision(0); 91 os << size_t(100.0 * diff.count() / total.count()) << "% | "; 100 if(parents.empty()) { 101 os << " N/A | "; 102 } else { 103 os << std::setw(7) << std::setprecision(0); 104 os << size_t(100.0 * diff.count() / parents.top().count()) << "% | "; 105 } 92 106 os << std::setw(5) << std::setprecision(0); 93 107 os << size_t(100.0 * diff.count() / total.count()) << "% "; … … 111 125 point_t begin; 112 126 point_t end; 127 128 static std::chrono::duration<double> last; 129 static std::stack<std::chrono::duration<double>> parents; 113 130 }; 114 131 115 132 std::stack<TimerNode *> nodes; 133 134 std::chrono::duration<double> TimerNode::last = {}; 135 std::stack<std::chrono::duration<double>> TimerNode::parents = {}; 116 136 117 137 void StartGlobal() { … … 139 159 auto global_end = std::chrono::high_resolution_clock::now(); 140 160 total = global_end - global_begin; 141 parent = total;142 161 143 162 size_t nc = 0; … … 161 180 162 181 Base::ForAll(top, 0, [&](Base::TreeImpl * node, size_t level) { 182 currl = level; 163 183 std::cerr << std::string(level * 4, ' '); 164 184 std::cerr << node->name; … … 168 188 std::cerr << " |"; 169 189 std::cerr << '\n'; 190 prevl = level; 170 191 }, true); 171 192
Note: See TracChangeset
for help on using the changeset viewer.