33 void print(std::ostream& os,
const std::string& title,
double total_ms = 0.0)
const
35 std::vector<std::pair<std::string, double>> sorted(
times_ms.begin(),
times_ms.end());
36 std::sort(sorted.begin(), sorted.end(),
37 [](
const auto& a,
const auto& b) { return a.second > b.second; });
39 os <<
"\n[PROFILE] " << title <<
"\n";
40 os <<
" " << std::left << std::setw(48) <<
"section"
41 << std::right << std::setw(12) <<
"total_ms"
42 << std::setw(10) <<
"calls"
43 << std::setw(12) <<
"ms/call";
44 if (total_ms > 0.0) os << std::setw(8) <<
"%";
47 for (
const auto& [key, total] : sorted)
49 const long call_count =
counts.at(key);
50 os <<
" " << std::left << std::setw(48) << key
51 << std::right << std::setw(12) << std::fixed << std::setprecision(2) << total
52 << std::setw(10) << call_count
53 << std::setw(12) << std::fixed << std::setprecision(3) << (total / double(call_count));
55 os << std::setw(7) << std::fixed << std::setprecision(1) << (total / total_ms * 100.0) <<
"%";