12
13
14
15
16
17
18
19
20
22QQuick3DParticleSystemLogging::QQuick3DParticleSystemLogging(QObject *parent)
28
29
30
31
32
33
34
35
36
38int QQuick3DParticleSystemLogging::loggingInterval()
const
40 return m_loggingInterval;
43void QQuick3DParticleSystemLogging::setLoggingInterval(
int interval)
45 if (m_loggingInterval == interval)
48 m_loggingInterval = interval;
49 Q_EMIT loggingIntervalChanged();
53
54
55
56
57
58
59int QQuick3DParticleSystemLogging::updates()
const
65
66
67
68
69
70
71int QQuick3DParticleSystemLogging::particlesMax()
const
73 return m_particlesMax;
77
78
79
80
81
82
83
84
85
86
87int QQuick3DParticleSystemLogging::particlesUsed()
const
89 return m_particlesUsed;
93
94
95
96
97
98
99float QQuick3DParticleSystemLogging::time()
const
105
106
107
108
109
110
111
112
113
114float QQuick3DParticleSystemLogging::timeAverage()
const
116 return m_timeAverage;
120
121
122
123
124
125
126
127
128
129
130float QQuick3DParticleSystemLogging::timeDeviation()
const
132 return m_timeDeviation;
135void QQuick3DParticleSystemLogging::updateTimes(qint64 time)
137 m_time =
float(time / 1000000.0) / m_updates;
139 m_totalTimesList.append(m_time);
142 const int MAX_TIMES = 100;
143 if (m_totalTimesList.size() > MAX_TIMES)
144 m_totalTimesList.removeFirst();
146 auto sortedTimes = m_totalTimesList;
147 std::sort(sortedTimes.begin(), sortedTimes.end());
152 if (sortedTimes.size() > 5) {
154 const int skipAmount = roundf(0.25f *
float(sortedTimes.size()));
155 const int maxItem = sortedTimes.size() - skipAmount;
157 double totalTime = 0.0;
158 float maxTime = 0.0f;
159 float minTime = FLT_MAX;
160 for (
int i = skipAmount; i < maxItem; i++) {
161 const float time = sortedTimes.at(i);
163 minTime = std::min(minTime, time);
164 maxTime = std::max(maxTime, time);
167 m_timeAverage =
float(totalTime / countAmount);
168 m_timeDeviation = maxTime - minTime;
169 Q_EMIT timeAverageChanged();
170 Q_EMIT timeDeviationChanged();
172 Q_EMIT timeChanged();
175void QQuick3DParticleSystemLogging::resetData()
181 m_timeAverage = 0.0f;
182 m_timeDeviation = 0.0f;
183 m_totalTimesList.clear();
184 Q_EMIT updatesChanged();
185 Q_EMIT particlesMaxChanged();
186 Q_EMIT particlesUsedChanged();
187 Q_EMIT timeChanged();
188 Q_EMIT timeAverageChanged();
189 Q_EMIT timeDeviationChanged();
Combined button and popup list for selecting options.