Guiliani  Version 2.5 revision 7293 (documentation build 13)
GUIProfiler.h
1/*
2* Copyright (C) TES Electronic Solutions GmbH,
3* All Rights Reserved.
4* Contact: info@guiliani.de
5*
6* This file is part of the Guiliani HMI framework
7* for the development of graphical user interfaces on embedded systems.
8*/
9
10#ifndef __GUIMEMPROFILE_H__
11#define __GUIMEMPROFILE_H__
12
13#include "GUIAnimatable.h"
14
15#include "GUIFontResource.h"
16#include "GUIRect.h"
17#include "eC_String.h"
18#include "eC_TList_doubleLinked.h"
19
20#include "GUIComponentManager.h"
21
22#define GETPROFILER CGUIComponentManager::GetInstance().GetProfiler()
23
82{
83public:
84 friend class CGUI;
85 friend class CGfxWrap;
86 friend class CGUIComponentManager;
87
88public:
91 {
92 INVALID_COUNTER_ID = -1,
93 DEFAULT_FPS,
94 DEFAULT_ABS_FPS
95 };
96
97public:
100 static void CreateInstance();
101
104 static void DeleteInstance();
105
106 // output methods
107
111 void SetActive(const eC_Bool& bActive);
112
116 eC_Bool IsActive() const
117 {
118 return m_bActive;
119 }
120
124 void SetDisplayActive(const eC_Bool& bActive);
125
129 eC_Bool IsDisplayActive() const
130 {
131 return m_bDisplayActive;
132 }
133
137 void SetConsoleActive(const eC_Bool& bActive);
138
142 eC_Bool IsConsoleActive() const
143 {
144 return m_bConsoleActive;
145 }
146
147 // profiling
148
152 void SetCPUProfilingActive(const eC_Bool& bActive);
153
157 eC_Bool IsCPUProfilingActive() const
158 {
159 return m_bCPUProfilingActive;
160 }
161
165 void SetMemoryProfilingActive(const eC_Bool& bActive);
166
171 {
172 return m_bMemoryProfilingActive;
173 }
174
178 void SetMemoryUsageBarActive(const eC_Bool& bActive);
179
184 {
185 return m_bMemoryUsageBarActive;
186 }
187
191 void SetGraphicsProfilingActive(const eC_Bool& bActive);
192
197 {
198 return m_bGraphicsProfilingActive;
199 }
200
204 void SetInvalidationActive(const eC_Bool& bActive);
205
209 eC_Bool IsInvalidationActive() const
210 {
211 return m_bInvalidationActive;
212 }
213
217 void SetFPSActive(const eC_Bool& bActive);
218
222 eC_Bool IsFPSActive() const
223 {
224 return m_bFPSActive;
225 }
226
230 void SetRuntimeActive(const eC_Bool& bActive);
231
235 eC_Bool GetRuntimeActive() const
236 {
237 return m_bRuntimeActive;
238 }
239
240 // memory-settings
241
245 void SetMemoryAvailable(const size_t& tMemoryAvailable);
246
250 size_t GetMemoryAvailable() const;
251
256 void SetMemoryThresholds(const eC_UInt& uiMemoryUsageWarning, const eC_UInt& uiMemoryUsageAlert);
257
262 void GetMemoryThresholds(eC_UInt& uiMemoryUsageWarning, eC_UInt& uiMemoryUsageAlert);
263
264 // general settings
265
269 void SetUpdateInterval(const eC_UInt& uiUpdateInterval);
270
274 void SetBackColor(const eC_UInt& uiBackColor);
275
279 void SetTextColor(const eC_UInt& uiTextColor);
280
284 void SetFont(const FontResource_t& eFontID);
285
290 void SetPosition(const eC_Value& vX, const eC_Value& vY);
291
296 void SetMemoryUsageBarPosition(const eC_Value& vX, const eC_Value& vY);
297
302 void SetMemoryUsageBarSize(const eC_Value& vWidth, const eC_Value& vHeight);
303
304 // getter for values
305
309 eC_UInt GetCPUUsage() const;
310
314 size_t GetMemoryUsed() const;
315
319 size_t GetMemoryMax() const;
320
324
328 size_t GetMemoryLargestBlock() const;
329
333
337 eC_UInt GetRedrawDuration() const;
338
342 eC_UInt GetRefreshDuration() const;
343
344 virtual void DoAnimate(const eC_Value& vTimes = eC_FromInt(1));
345
346private:
349 void BeginLoop();
350
354 void BeginProcess();
355
358 void EndLoop();
359
362 void StartMeasurementFPS();
363
366 void EndMeasurementFPS();
367
370 void StartRedraw();
371
374 void EndRedraw();
375
378 void StartRefresh();
379
382 void EndRefresh();
383
387 void DisplayInvalidation(const CGUIRect& kRect);
388
389private:
392 CGUIProfiler();
393
395 virtual ~CGUIProfiler();
396
398 void Update();
399
401 void Draw() const;
402
403 void DrawMemoryBar() const;
404
406 void ConsoleOutput() const;
407
408 void CalcBackRectangle();
409
414 FPSCounterID AddCounter(const eC_String& kFPSTextPrefix);
415
419 eC_UInt GetFPS(const FPSCounterID& eCounterID = DEFAULT_FPS) const;
420
424 void StartMeasurement(const FPSCounterID& eCounterID) const;
425
429 void StopMeasurement(const FPSCounterID& eCounterID) const;
430
431private:
435 class CGUIFramerateCounter
436 {
437 public:
439 CGUIFramerateCounter();
440
447 CGUIFramerateCounter(eC_String kFPSTextPrefix);
448
450 virtual ~CGUIFramerateCounter();
451
455 eC_UInt GetFPS() const;
456
461 eC_String GetText() const;
462
464 void CountFrame();
465
467 void StartMeasurement();
468
470 void StopMeasurement();
471
473 void Recalculate();
474
475 public:
476 eC_UInt m_uiFrames;
477 eC_Time64 m_kStartTime;
478 eC_Time64 m_kDeltaTime;
479 eC_UInt m_uiFPS;
480 eC_String m_kFPSTextPrefix;
481 eC_String m_kFPSText;
482 };
483
484private:
488 void CountFrame(const FPSCounterID& eCounterID) const;
489
491 void Calculate();
492
497 CGUIFramerateCounter* GetCounter(const FPSCounterID& eCounterID) const;
498
499 void CheckUpdateTimer();
500
501 void UpdateMemoryValues();
502
503private:
504 eC_Bool m_bActive;
505 eC_Bool m_bDisplayActive;
506 eC_Bool m_bConsoleActive;
507 eC_Bool m_bCPUProfilingActive;
508 eC_Bool m_bMemoryProfilingActive;
509 eC_Bool m_bMemoryUsageBarActive;
510 eC_Bool m_bGraphicsProfilingActive;
511 eC_Bool m_bInvalidationActive;
512 eC_Bool m_bFPSActive;
513 eC_Bool m_bRuntimeActive;
514
515 eC_UInt m_uiUpdateInterval;
516
517 eC_UInt m_uiBackColor;
518 eC_UInt m_uiTextColor;
519 FontResource_t m_eFontID;
520
521 eC_Value m_vPosX;
522 eC_Value m_vPosY;
523 eC_UInt m_uiLineCount;
524 eC_Value m_vLineHeight;
525
526 eC_Value m_vMemoryBarPosX;
527 eC_Value m_vMemoryBarPosY;
528 eC_Value m_vMemoryBarWidth;
529 eC_Value m_vMemoryBarHeight;
530
531 CGUIRect m_kBackRect;
532
533 eC_Time64 m_tLoopBegin;
534 eC_Time64 m_tProcessBegin;
535
536 eC_UInt m_uiCPUUsage;
537 size_t m_tMemoryUsed;
538 size_t m_tMemoryUsageWarning;
539 size_t m_tMemoryUsageAlert;
540 size_t m_tMemoryUsedMax;
541 size_t m_tMemoryUsedLargestBlock;
542 size_t m_tMemoryNumAllocs;
543 eC_UInt m_uiStartRedraw;
544 eC_UInt m_uiLastRedraw;
545 eC_UInt m_uiStartRefresh;
546 eC_UInt m_uiLastRefresh;
547
548 eC_String m_kCPUUsage;
549 eC_String m_kMemoryUsed;
550 eC_String m_kMemoryMax;
551 eC_String m_kMemoryLargestBlock;
552 eC_String m_kMemoryNumAllocs;
553 eC_String m_kTimeRedraw;
554 eC_String m_kTimeRefresh;
555 eC_String m_kTimeRuntime;
556
557 eC_Value m_vScreenWidth;
558 eC_Value m_vScreenHeight;
559 eC_Value m_vMemoryUsageCurrent;
560 eC_Value m_vMemoryUsageWarning;
561 eC_Value m_vMemoryUsageAlert;
562 eC_Value m_vMemoryUsageMax;
563
564 eC_Bool m_bNeedsRedraw;
565
566 eC_Time64 m_tStartTime;
567
568 // FPS
570 eC_Time64 m_kInternalTimer;
571
574
576 FPSCounterID m_eLastCounterID;
577};
578
579#endif
Helper Macros in Guiliani
FontResource_t
List of font resource ids.
Definition: GUIFontResource.h:54
Base interface for animation callbacks.
Definition: GUIAnimatable.h:51
central component-manager
Definition: GUIComponentManager.h:62
GUI base class for any Guiliani application.
Definition: GUI.h:47
Definition: GUIProfiler.h:82
void SetCPUProfilingActive(const eC_Bool &bActive)
size_t GetMemoryAvailable() const
virtual void DoAnimate(const eC_Value &vTimes=eC_FromInt(1))
void SetFPSActive(const eC_Bool &bActive)
eC_UInt GetRedrawDuration() const
void GetMemoryThresholds(eC_UInt &uiMemoryUsageWarning, eC_UInt &uiMemoryUsageAlert)
void SetTextColor(const eC_UInt &uiTextColor)
void SetMemoryUsageBarSize(const eC_Value &vWidth, const eC_Value &vHeight)
eC_Bool IsMemoryUsageBarActive() const
Definition: GUIProfiler.h:183
void SetBackColor(const eC_UInt &uiBackColor)
eC_Bool IsDisplayActive() const
Definition: GUIProfiler.h:129
void SetInvalidationActive(const eC_Bool &bActive)
static void DeleteInstance()
void SetFont(const FontResource_t &eFontID)
void SetMemoryAvailable(const size_t &tMemoryAvailable)
void SetActive(const eC_Bool &bActive)
size_t GetMemoryUsed() const
eC_UInt GetCPUUsage() const
eC_Bool IsInvalidationActive() const
Definition: GUIProfiler.h:209
void SetMemoryUsageBarPosition(const eC_Value &vX, const eC_Value &vY)
eC_Bool IsCPUProfilingActive() const
Definition: GUIProfiler.h:157
void SetMemoryUsageBarActive(const eC_Bool &bActive)
eC_Bool GetRuntimeActive() const
Definition: GUIProfiler.h:235
void SetMemoryProfilingActive(const eC_Bool &bActive)
void ClearMemoryMax()
size_t GetMemoryLargestBlock() const
size_t GetMemoryMax() const
void SetConsoleActive(const eC_Bool &bActive)
void ClearMemoryLargestBlock()
void SetPosition(const eC_Value &vX, const eC_Value &vY)
eC_Bool IsGraphicsProfilingActive() const
Definition: GUIProfiler.h:196
static void CreateInstance()
void SetUpdateInterval(const eC_UInt &uiUpdateInterval)
eC_Bool IsFPSActive() const
Definition: GUIProfiler.h:222
void SetRuntimeActive(const eC_Bool &bActive)
eC_Bool IsMemoryProfilingActive() const
Definition: GUIProfiler.h:170
void SetDisplayActive(const eC_Bool &bActive)
FPSCounterID
Definition: GUIProfiler.h:91
eC_Bool IsConsoleActive() const
Definition: GUIProfiler.h:142
eC_UInt GetRefreshDuration() const
eC_Bool IsActive() const
Definition: GUIProfiler.h:116
void SetMemoryThresholds(const eC_UInt &uiMemoryUsageWarning, const eC_UInt &uiMemoryUsageAlert)
void SetGraphicsProfilingActive(const eC_Bool &bActive)
Helper class to supply a platform independent rectangle implementation.
Definition: GUIRect.h:63
The graphics wrapper base class.
Definition: GfxWrap.h:84