Guiliani  Version 2.6 revision 7293 (documentation build 12)
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#include "GUICompositeObject.h"
15
16#include "GUIFontResource.h"
17#include "GUIRect.h"
18#include "eC_String.h"
19#include "eC_TList_doubleLinked.h"
20
21#include "GUIComponentManager.h"
22
23#define GETPROFILER CGUIComponentManager::GetInstance().GetProfiler()
24
83{
84public:
85 friend class CGUI;
86 friend class CGfxWrap;
87 friend class CGUIComponentManager;
88
89public:
92 {
93 INVALID_COUNTER_ID = -1,
94 DEFAULT_FPS,
95 DEFAULT_ABS_FPS
96 };
97
98public:
101 static void CreateInstance();
102
105 static void DeleteInstance();
106
107 // output methods
108
112 void SetActive(const eC_Bool& bActive);
113
117 eC_Bool IsActive() const
118 {
119 return m_bActive;
120 }
121
125 void SetDisplayActive(const eC_Bool& bActive);
126
130 eC_Bool IsDisplayActive() const
131 {
132 return m_bDisplayActive;
133 }
134
138 void SetConsoleActive(const eC_Bool& bActive);
139
143 eC_Bool IsConsoleActive() const
144 {
145 return m_bConsoleActive;
146 }
147
148 // profiling
149
153 void SetCPUProfilingActive(const eC_Bool& bActive);
154
158 eC_Bool IsCPUProfilingActive() const
159 {
160 return m_bCPUProfilingActive;
161 }
162
166 void SetMemoryProfilingActive(const eC_Bool& bActive);
167
172 {
173 return m_bMemoryProfilingActive;
174 }
175
179 void SetMemoryUsageBarActive(const eC_Bool& bActive);
180
185 {
186 return m_bMemoryUsageBarActive;
187 }
188
192 void SetGraphicsProfilingActive(const eC_Bool& bActive);
193
198 {
199 return m_bGraphicsProfilingActive;
200 }
201
205 void SetInvalidationActive(const eC_Bool& bActive);
206
210 eC_Bool IsInvalidationActive() const
211 {
212 return m_bInvalidationActive;
213 }
214
218 void SetFPSActive(const eC_Bool& bActive);
219
223 eC_Bool IsFPSActive() const
224 {
225 return m_bFPSActive;
226 }
227
231 void SetRuntimeActive(const eC_Bool& bActive);
232
236 eC_Bool GetRuntimeActive() const
237 {
238 return m_bRuntimeActive;
239 }
240
244 void SetObjectCountActive(const eC_Bool& bActive);
245
249 eC_Bool GetObjectCountActive() const
250 {
251 return m_bObjectCountActive;
252 }
253
254 // memory-settings
255
259 void SetMemoryAvailable(const size_t& tMemoryAvailable);
260
264 size_t GetMemoryAvailable() const;
265
270 void SetMemoryThresholds(const size_t& uiMemoryUsageWarning, const size_t& uiMemoryUsageAlert);
271
276 void GetMemoryThresholds(size_t& uiMemoryUsageWarning, size_t& uiMemoryUsageAlert);
277
278 // general settings
279
283 void SetUpdateInterval(const eC_UInt& uiUpdateInterval);
284
288 void SetBackColor(const eC_UInt& uiBackColor);
289
293 void SetTextColor(const eC_UInt& uiTextColor);
294
298 void SetFont(const FontResource_t& eFontID);
299
304 void SetPosition(const eC_Value& vX, const eC_Value& vY);
305
310 void SetMemoryUsageBarPosition(const eC_Value& vX, const eC_Value& vY);
311
316 void SetMemoryUsageBarSize(const eC_Value& vWidth, const eC_Value& vHeight);
317
318 // getter for values
319
323 eC_UInt GetCPUUsage() const;
324
328 size_t GetMemoryUsed() const;
329
333 size_t GetMemoryMax() const;
334
338
342 size_t GetMemoryLargestBlock() const;
343
347
351 eC_UInt GetRedrawDuration() const;
352
356 eC_UInt GetRefreshDuration() const;
357
361 eC_UInt GetObjectCount();
362
363 virtual void DoAnimate(const eC_Value& vTimes = eC_FromInt(1));
364
365private:
368 void BeginLoop();
369
373 void BeginProcess();
374
377 void EndLoop();
378
381 void StartMeasurementFPS();
382
385 void EndMeasurementFPS();
386
389 void StartRedraw();
390
393 void EndRedraw();
394
397 void StartRefresh();
398
401 void EndRefresh();
402
406 void DisplayInvalidation(const CGUIRect& kRect);
407
412 void GetObjectCount(CGUICompositeObject* pkContainer, eC_UInt& ruiCount);
413
414private:
417 CGUIProfiler();
418
420 virtual ~CGUIProfiler();
421
423 void Update();
424
426 void Draw() const;
427
428 void DrawMemoryBar() const;
429
431 void ConsoleOutput() const;
432
433 void CalcBackRectangle();
434
439 FPSCounterID AddCounter(const eC_String& kFPSTextPrefix);
440
444 eC_UInt GetFPS(const FPSCounterID& eCounterID = DEFAULT_FPS) const;
445
449 void StartMeasurement(const FPSCounterID& eCounterID) const;
450
454 void StopMeasurement(const FPSCounterID& eCounterID) const;
455
456private:
460 class CGUIFramerateCounter
461 {
462 public:
464 CGUIFramerateCounter();
465
472 CGUIFramerateCounter(eC_String kFPSTextPrefix);
473
475 virtual ~CGUIFramerateCounter();
476
480 eC_UInt GetFPS() const;
481
486 eC_String GetText() const;
487
489 void CountFrame();
490
492 void StartMeasurement();
493
495 void StopMeasurement();
496
498 void Recalculate();
499
500 public:
501 eC_UInt m_uiFrames;
502 eC_Time64 m_kStartTime;
503 eC_Time64 m_kDeltaTime;
504 eC_UInt m_uiFPS;
505 eC_String m_kFPSTextPrefix;
506 eC_String m_kFPSText;
507 };
508
509private:
513 void CountFrame(const FPSCounterID& eCounterID) const;
514
516 void Calculate();
517
522 CGUIFramerateCounter* GetCounter(const FPSCounterID& eCounterID) const;
523
524 void CheckUpdateTimer();
525
526 void UpdateMemoryValues();
527
528 void UpdateObjectCount();
529
530private:
531 eC_Bool m_bActive;
532 eC_Bool m_bDisplayActive;
533 eC_Bool m_bConsoleActive;
534 eC_Bool m_bCPUProfilingActive;
535 eC_Bool m_bMemoryProfilingActive;
536 eC_Bool m_bMemoryUsageBarActive;
537 eC_Bool m_bGraphicsProfilingActive;
538 eC_Bool m_bInvalidationActive;
539 eC_Bool m_bFPSActive;
540 eC_Bool m_bRuntimeActive;
541 eC_Bool m_bObjectCountActive;
542
543 eC_UInt m_uiUpdateInterval;
544
545 eC_UInt m_uiBackColor;
546 eC_UInt m_uiTextColor;
547 FontResource_t m_eFontID;
548
549 eC_Value m_vPosX;
550 eC_Value m_vPosY;
551 eC_UInt m_uiLineCount;
552 eC_Value m_vLineHeight;
553
554 eC_Value m_vMemoryBarPosX;
555 eC_Value m_vMemoryBarPosY;
556 eC_Value m_vMemoryBarWidth;
557 eC_Value m_vMemoryBarHeight;
558
559 CGUIRect m_kBackRect;
560
561 eC_Time64 m_tLoopBegin;
562 eC_Time64 m_tProcessBegin;
563
564 eC_UInt m_uiCPUUsage;
565 eC_UInt m_uiLastCPUUsage;
566 size_t m_tMemoryUsed;
567 size_t m_tMemoryUsageWarning;
568 size_t m_tMemoryUsageAlert;
569 size_t m_tMemoryUsedMax;
570 size_t m_tMemoryUsedLargestBlock;
571 size_t m_tMemoryNumAllocs;
572 eC_UInt m_uiStartRedraw;
573 eC_UInt m_uiLastRedraw;
574 eC_UInt m_uiDurationRedraw;
575 eC_UInt m_uiStartRefresh;
576 eC_UInt m_uiLastRefresh;
577 eC_UInt m_uiDurationRefresh;
578
579 eC_String m_kCPUUsage;
580 eC_String m_kMemoryUsed;
581 eC_String m_kMemoryMax;
582 eC_String m_kMemoryLargestBlock;
583 eC_String m_kMemoryNumAllocs;
584 eC_String m_kTimeRedraw;
585 eC_String m_kTimeRefresh;
586 eC_String m_kTimeRuntime;
587 eC_String m_kObjectCount;
588
589 eC_Value m_vScreenWidth;
590 eC_Value m_vScreenHeight;
591 eC_Value m_vMemoryUsageCurrent;
592 eC_Value m_vMemoryUsageWarning;
593 eC_Value m_vMemoryUsageAlert;
594 eC_Value m_vMemoryUsageMax;
595
596 eC_UInt m_uiObjectCount;
597
598 eC_Bool m_bNeedsRedraw;
599 eC_Bool m_bRectChanged;
600
601 eC_Time64 m_tStartTime;
602
603 // FPS
605 eC_Time64 m_kInternalTimer;
606
609
611 FPSCounterID m_eLastCounterID;
612};
613
614#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
This is the Guiliani base class for all composite objects.
Definition: GUICompositeObject.h:70
GUI base class for any Guiliani application.
Definition: GUI.h:39
Definition: GUIProfiler.h:83
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 SetTextColor(const eC_UInt &uiTextColor)
void SetMemoryUsageBarSize(const eC_Value &vWidth, const eC_Value &vHeight)
eC_Bool IsMemoryUsageBarActive() const
Definition: GUIProfiler.h:184
eC_Bool GetObjectCountActive() const
Definition: GUIProfiler.h:249
void SetBackColor(const eC_UInt &uiBackColor)
eC_Bool IsDisplayActive() const
Definition: GUIProfiler.h:130
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 GetObjectCount()
eC_UInt GetCPUUsage() const
eC_Bool IsInvalidationActive() const
Definition: GUIProfiler.h:210
void SetMemoryUsageBarPosition(const eC_Value &vX, const eC_Value &vY)
eC_Bool IsCPUProfilingActive() const
Definition: GUIProfiler.h:158
void SetMemoryUsageBarActive(const eC_Bool &bActive)
eC_Bool GetRuntimeActive() const
Definition: GUIProfiler.h:236
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 GetMemoryThresholds(size_t &uiMemoryUsageWarning, size_t &uiMemoryUsageAlert)
void SetObjectCountActive(const eC_Bool &bActive)
void SetPosition(const eC_Value &vX, const eC_Value &vY)
eC_Bool IsGraphicsProfilingActive() const
Definition: GUIProfiler.h:197
static void CreateInstance()
void SetUpdateInterval(const eC_UInt &uiUpdateInterval)
eC_Bool IsFPSActive() const
Definition: GUIProfiler.h:223
void SetRuntimeActive(const eC_Bool &bActive)
eC_Bool IsMemoryProfilingActive() const
Definition: GUIProfiler.h:171
void SetMemoryThresholds(const size_t &uiMemoryUsageWarning, const size_t &uiMemoryUsageAlert)
void SetDisplayActive(const eC_Bool &bActive)
FPSCounterID
Definition: GUIProfiler.h:92
eC_Bool IsConsoleActive() const
Definition: GUIProfiler.h:143
eC_UInt GetRefreshDuration() const
eC_Bool IsActive() const
Definition: GUIProfiler.h:117
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:88