| 98 | } // namespace |
| 99 | |
| 100 | void ProfilerUI::render() |
| 101 | { |
| 102 | updateEventData(); |
| 103 | updateGraphData(); |
| 104 | |
| 105 | renderOptions(); |
| 106 | |
| 107 | // Compute column widths. |
| 108 | float columnWidth[kColumnCount]; |
| 109 | for (size_t i = 0; i < kColumnCount; ++i) |
| 110 | columnWidth[i] = ImGui::CalcTextSize(kColumnTitle[i]).x + kPadding; |
| 111 | for (const auto& eventData : mEventData) |
| 112 | { |
| 113 | columnWidth[0] = |
| 114 | std::max(columnWidth[0], ImGui::CalcTextSize(eventData.name.c_str()).x + eventData.level * kIndentWidth + kPadding); |
| 115 | } |
| 116 | |
| 117 | float startY; |
| 118 | float endY; |
| 119 | size_t newHighlightIndex = -1; |
| 120 | |
| 121 | // Draw table (last column is used for graph). |
| 122 | ImGui::Columns(kColumnCount + 1, "#events", false); |
| 123 | for (size_t col = 0; col < kColumnCount; ++col) |
| 124 | { |
| 125 | ImGui::SetColumnWidth((int)col, columnWidth[col]); |
| 126 | ImGui::TextUnformatted(kColumnTitle[col]); |
| 127 | ImGui::Dummy(ImVec2(0.f, kHeaderSpacing)); |
| 128 | |
| 129 | if (col == 0) |
| 130 | startY = ImGui::GetCursorPosY(); |
| 131 | |
| 132 | for (size_t i = 0; i < mEventData.size(); ++i) |
| 133 | { |
| 134 | const auto& eventData = mEventData[i]; |
| 135 | auto pEvent = eventData.pEvent; |
| 136 | |
| 137 | if (col == 0) // Event name |
| 138 | { |
| 139 | float indent = eventData.level * kIndentWidth; |
| 140 | if (indent > 0.f) |
| 141 | ImGui::Indent(indent); |
| 142 | auto color = (i == mHighlightIndex) ? ImColor(kHighlightColor) : ImColor(ImGui::GetStyleColorVec4(ImGuiCol_Text)); |
| 143 | ImGui::TextColored(color, "%s", eventData.name.c_str()); |
| 144 | if (indent > 0.f) |
| 145 | ImGui::Unindent(indent); |
| 146 | } |
| 147 | else if (col == 1) // CPU time |
| 148 | { |
| 149 | ImGui::Text("%.2f ms", eventData.cpuTime); |
| 150 | if (ImGui::IsItemHovered()) |
| 151 | { |
| 152 | auto stats = eventData.pEvent->computeCpuTimeStats(); |
| 153 | ImGui::BeginTooltip(); |
| 154 | ImGui::Text( |
| 155 | "%s\nMin: %.2f\nMax: %.2f\nMean: %.2f\nStdDev: %.2f", |
| 156 | eventData.name.c_str(), |
| 157 | stats.min, |
nothing calls this directly
no test coverage detected