Pioneer
PerfInfo.h
Go to the documentation of this file.
1 // Copyright © 2008-2023 Pioneer Developers. See AUTHORS.txt for details
2 // Licensed under the terms of the GPL v3. See licenses/GPL-3.txt
3 
4 #pragma once
5 
6 #include "PerfStats.h"
7 #include "RefCounted.h"
8 #include <array>
9 #include <memory>
10 
11 namespace PiGui {
12 
13  class PerfInfo {
14  public:
17 
18  enum CounterType {
22  };
23 
24  // Information about the current process memory usage in KB.
25  struct MemoryInfo {
27  size_t peakMemSize;
28  };
29  struct ImGuiState;
30 
31  void Draw();
32 
33  // Update with current frame and physics update time in ms
34  void UpdateCounter(CounterType counter, float counterTime);
35  void ClearCounter(CounterType counter);
36 
37  void Update(float deltaTime);
38  void UpdateFrameInfo(int framesThisSecond, int physFramesThisSecond);
39 
40  void SetShowDebugInfo(bool open);
41  void SetUpdatePause(bool pause);
42 
43  private:
44  void DrawPerfWindow();
45  void DrawTextureCache();
46  void DrawTextureInspector();
47 
48  void DrawRendererStats();
49  void DrawWorldViewStats();
50  void DrawImGuiStats();
51  void DrawInputDebug();
52  void DrawStatList(const Perf::Stats::FrameInfo &fi);
53 
54  static const int NUM_FRAMES = 60;
55  struct CounterInfo {
56  std::array<float, NUM_FRAMES> history;
57  float average = 0.;
58  float min = 0.;
59  float max = 0.;
60  };
61 
62  CounterInfo &GetCounter(CounterType ct);
63 
64  CounterInfo m_fpsCounter;
65  CounterInfo m_physCounter;
66  CounterInfo m_piguiCounter;
67 
68  MemoryInfo process_mem;
69  size_t lua_mem = 0;
70  float framesThisSecond = 0;
71  float physFramesThisSecond = 0;
72 
73  float lastUpdateTime = 0;
74 
75  ImGuiState *m_state;
76  };
77 
78 } // namespace PiGui
std::map< std::string, uint32_t > FrameInfo
Definition: PerfStats.h:26
Definition: PerfInfo.h:13
void UpdateCounter(CounterType counter, float counterTime)
void Update(float deltaTime)
void SetShowDebugInfo(bool open)
void UpdateFrameInfo(int framesThisSecond, int physFramesThisSecond)
CounterType
Definition: PerfInfo.h:18
@ COUNTER_FPS
Definition: PerfInfo.h:19
@ COUNTER_PHYS
Definition: PerfInfo.h:20
@ COUNTER_PIGUI
Definition: PerfInfo.h:21
void SetUpdatePause(bool pause)
void ClearCounter(CounterType counter)
Definition: LuaBody.cpp:29
Definition: PerfInfo.h:25
size_t currentMemSize
Definition: PerfInfo.h:26
size_t peakMemSize
Definition: PerfInfo.h:27