129 delta_type children_time()
const
131 delta_type s = delta_type();
132 for (
typename std::map<std::string, profile_unit>::const_iterator c = children.begin(); c != children.end(); c++)
133 s += c->second.length;
137 size_t total_width(
const std::string& name,
int level)
const
139 size_t w = name.size() + level;
140 for (
typename std::map<std::string, profile_unit>::const_iterator c = children.begin(); c != children.end(); c++)
141 w = std::max(w, c->second.total_width(c->first, level + SHIFT_WIDTH));
145 void print(std::ostream& out,
const std::string& name,
146 int level, delta_type total,
size_t width)
const
150 out <<
"[" << setw(level) <<
"";
151 print_line(out, name, length, 100 * length / total, width - level);
153 if (children.size()) {
154 delta_type val = length - children_time();
155 double perc = 100.0 * val / total;
158 out <<
"[" << setw(level + 1) <<
"";
159 print_line(out,
"self", val, perc, width - level - 1);
163 for (
typename std::map<std::string, profile_unit>::const_iterator c = children.begin(); c != children.end(); c++)
164 c->second.print(out, c->first, level + SHIFT_WIDTH, total, width);
167 void print_line(std::ostream& out,
const std::string& name,
168 delta_type time,
double perc,
size_t width)
const
173 << setw(width - name.size()) <<
""
175 << fixed << setprecision(3) << time <<
" " <<
"s"
176 <<
"] (" << fixed << setprecision(2) << setw(6) << perc <<
"%)"
183 std::map<std::string, profile_unit> children;