double children_time() const { double tm = 0; for(auto c = children.begin(); c != children.end(); c++) tm += (*c)->watch.total(); return tm; }
uint max_line_width(uint level) const { uint w = name.size() + level; for(auto c = children.begin(); c != children.end(); c++) w = std::max(w, (*c)->max_line_width(level + shift_width)); return w; }
double children_time() const { double tm = 0; for(auto c = children.begin(); c != children.end(); c++) tm += (*c)->length; return tm; }
void print(std::ostream &out, uint level, double total, uint width) const { using namespace std; out << "[" << setw(level) << ""; print_line(out, name, length, 100 * length / total, width - level); if (!children.empty()) { double sec = length - children_time(); double perc = 100 * sec / total; if (perc > 1e-1) { out << "[" << setw(level + 1) << ""; print_line(out, "self", sec, perc, width - level - 1); } } for(auto c = children.begin(); c != children.end(); c++) (*c)->print(out, level + shift_width, total, width); }