A 2D tile-based sandbox game.
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

PerfCounter.cc 1.1KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152
  1. #include "PerfCounter.h"
  2. #include <imgui.h>
  3. #include <imgui_plot.h>
  4. #include "util.h"
  5. namespace Swan {
  6. void PerfCounter::render() {
  7. Deferred<ImGui::End> win;
  8. if (!ImGui::Begin("Perf Stats"))
  9. return;
  10. std::array<float, 64> buf;
  11. ImGui::PlotConfig conf;
  12. conf.values = { .ys = buf.data(), .count = 64 };
  13. conf.scale = { 0, 1 / 30.0 };
  14. conf.frame_size = { ImGui::GetWindowContentRegionWidth(), 30 },
  15. total_time_.fill(buf);
  16. ImGui::Text("Total Time");
  17. ImGui::Plot("Total Time", conf);
  18. render_present_.fill(buf);
  19. ImGui::Text("Render Present");
  20. ImGui::Plot("Render Present", conf);
  21. frame_time_.fill(buf);
  22. ImGui::Text("Frame Times");
  23. ImGui::Plot("Frame Times", conf);
  24. game_update_.fill(buf);
  25. ImGui::Text("Game Update");
  26. ImGui::Plot("Game Update", conf);
  27. game_draw_.fill(buf);
  28. ImGui::Text("Game Draw");
  29. ImGui::Plot("Game Draw", conf);
  30. game_tick_.fill(buf);
  31. ImGui::Text("Game Tick");
  32. ImGui::Plot("Game Tick", conf);
  33. game_updates_per_frame_.fill(buf);
  34. conf.scale = { 0, 3 };
  35. ImGui::Text("Game Updates Per Frame");
  36. ImGui::Plot("Game Updates Per Frame", conf);
  37. }
  38. }