Skip to content

Commit 2eba801

Browse files
committed
remove an alloc from the profiler
1 parent 69733cc commit 2eba801

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

src/time/profiler.cpp

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -456,7 +456,9 @@ void EndRegion()
456456

457457
auto& region = gProfilerData->regionData[gProfilerData->currentRegion];
458458
region.endTime = timer_get_elapsed(gTimer).count();
459-
region.name = std::format("{:.2f}ms", float(timer_to_ms(nanoseconds(region.endTime - region.startTime))));
459+
460+
// Reconstructed at display time, not capture time!!
461+
//region.name = std::format("{:.2f}ms", float(timer_to_ms(nanoseconds(region.endTime - region.startTime))));
460462

461463
gProfilerData->currentRegion++;
462464
}
@@ -1083,6 +1085,7 @@ void ShowProfile()
10831085
pDrawList->AddLine(ImVec2(regionMin.x + float(xFrameMarker), regionMin.y), ImVec2(regionMin.x + float(xFrameMarker), regionMax.y), frameMarkerColor, 1.0f);
10841086

10851087
// Frame text
1088+
frameInfo.name = std::format("F{}: {:.2f}ms", frameIndex, float(timer_to_ms(nanoseconds(frameInfo.endTime - frameInfo.startTime))));
10861089
if ((xFrameMarker - lastFrameX) > ImGui::CalcTextSize(frameInfo.name.c_str()).x)
10871090
{
10881091
pDrawList->AddText(pFont, smallFontSize, ImVec2(regionMin.x + float(xFrameMarker) + textPadding.x, regionMin.y + textPadding.y), 0xFFAAAAAA, frameInfo.name.c_str(), NULL, 0.0f, nullptr);

0 commit comments

Comments
 (0)