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

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354
  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 win([]{ ImGui::End(); });
  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 / 60.0 };
  14. conf.scale.min = 0;
  15. conf.scale.max = 1 / 60.0;
  16. conf.frame_size = { ImGui::GetWindowContentRegionWidth(), 20 },
  17. total_time_.fill(buf);
  18. ImGui::Text("Total Time");
  19. ImGui::Plot("Total Time", conf);
  20. render_present_.fill(buf);
  21. ImGui::Text("Render Present");
  22. ImGui::Plot("Render Present", conf);
  23. frame_time_.fill(buf);
  24. ImGui::Text("Frame Times");
  25. ImGui::Plot("Frame Times", conf);
  26. game_update_.fill(buf);
  27. ImGui::Text("Game Update");
  28. ImGui::Plot("Game Update", conf);
  29. game_draw_.fill(buf);
  30. ImGui::Text("Game Draw");
  31. ImGui::Plot("Game Draw", conf);
  32. game_tick_.fill(buf);
  33. ImGui::Text("Game Tick");
  34. ImGui::Plot("Game Tick", conf);
  35. game_updates_per_frame_.fill(buf);
  36. conf.scale = { 0, 5 };
  37. ImGui::Text("Game Updates Per Frame");
  38. ImGui::Plot("Game Updates Per Frame", conf);
  39. }
  40. }