TexGen
ShinyData.h
Go to the documentation of this file.
1/*
2The zlib/libpng License
3
4Copyright (c) 2007 Aidin Abedi (www.*)
5
6This software is provided 'as-is', without any express or implied warranty. In no event will
7the authors be held liable for any damages arising from the use of this software.
8
9Permission is granted to anyone to use this software for any purpose, including commercial
10applications, and to alter it and redistribute it freely, subject to the following
11restrictions:
12
13 1. The origin of this software must not be misrepresented; you must not claim that
14 you wrote the original software. If you use this software in a product,
15 an acknowledgment in the product documentation would be appreciated but is
16 not required.
17
18 2. Altered source versions must be plainly marked as such, and must not be
19 misrepresented as being the original software.
20
21 3. This notice may not be removed or altered from any source distribution.
22*/
23
24#ifndef SHINY_DATA_H
25#define SHINY_DATA_H
26
27#include "ShinyPrereqs.h"
28
29namespace Shiny {
30
31
32//-----------------------------------------------------------------------------
33
35 uint32_t entryCount;
37 };
38
39
40//-----------------------------------------------------------------------------
41
42 struct ProfileData {
43
44 template <typename T>
45 struct Data {
46 T cur;
47 float avg;
48
49 void computeAverage(float a_damping) { avg = a_damping * (avg - cur) + cur; }
50 void clear(void) { cur = 0; avg = 0; }
51 };
52
53
57
58
59 tick_t totalTicksCur(void) const { return selfTicks.cur + childTicks.cur; }
60 float totalTicksAvg(void) const { return selfTicks.avg + childTicks.avg; }
61
62 void computeAverage(float a_damping) {
63 entryCount.computeAverage(a_damping);
64 selfTicks.computeAverage(a_damping);
65 childTicks.computeAverage(a_damping);
66 }
67
68 void clearAll(void) {
69 entryCount.clear();
70 selfTicks.clear();
71 childTicks.clear();
72 }
73
74 void clearCurrent(void) {
75 entryCount.cur = 0;
76 selfTicks.cur = 0;
77 childTicks.cur = 0;
78 }
79 };
80
81
82} // namespace Shiny
83
84#endif // ifndef SHINY_*_H
uint64_t tick_t
Definition: ShinyPrereqs.h:77
void computeAverage(float a_damping)
Definition: ShinyData.h:49
tick_t totalTicksCur(void) const
Definition: ShinyData.h:59
void computeAverage(float a_damping)
Definition: ShinyData.h:62
void clearCurrent(void)
Definition: ShinyData.h:74
float totalTicksAvg(void) const
Definition: ShinyData.h:60
void clearAll(void)
Definition: ShinyData.h:68
Data< tick_t > childTicks
Definition: ShinyData.h:56
Data< tick_t > selfTicks
Definition: ShinyData.h:55
Data< uint32_t > entryCount
Definition: ShinyData.h:54