10
11
12
13
14
15
16
17
18
20QQuick3DParticleSystemLogging::QQuick3DParticleSystemLogging(QObject *parent)
26
27
28
29
30
31
32
33
34
36int QQuick3DParticleSystemLogging::loggingInterval()
const
38 return m_loggingInterval;
41void QQuick3DParticleSystemLogging::setLoggingInterval(
int interval)
43 if (m_loggingInterval == interval)
46 m_loggingInterval = interval;
47 Q_EMIT loggingIntervalChanged();
51
52
53
54
55
56
57int QQuick3DParticleSystemLogging::updates()
const
63
64
65
66
67
68
69int QQuick3DParticleSystemLogging::particlesMax()
const
71 return m_particlesMax;
75
76
77
78
79
80
81
82
83
84
85int QQuick3DParticleSystemLogging::particlesUsed()
const
87 return m_particlesUsed;
91
92
93
94
95
96
97float QQuick3DParticleSystemLogging::time()
const
103
104
105
106
107
108
109
110
111
112float QQuick3DParticleSystemLogging::timeAverage()
const
114 return m_timeAverage;
118
119
120
121
122
123
124
125
126
127
128float QQuick3DParticleSystemLogging::timeDeviation()
const
130 return m_timeDeviation;
133void QQuick3DParticleSystemLogging::updateTimes(qint64 time)
135 m_time =
float(time / 1000000.0) / m_updates;
137 m_totalTimesList.append(m_time);
140 const int MAX_TIMES = 100;
141 if (m_totalTimesList.size() > MAX_TIMES)
142 m_totalTimesList.removeFirst();
144 auto sortedTimes = m_totalTimesList;
145 std::sort(sortedTimes.begin(), sortedTimes.end());
150 if (sortedTimes.size() > 5) {
152 const int skipAmount = roundf(0.25f *
float(sortedTimes.size()));
153 const int maxItem = sortedTimes.size() - skipAmount;
155 double totalTime = 0.0;
156 float maxTime = 0.0f;
157 float minTime = FLT_MAX;
158 for (
int i = skipAmount; i < maxItem; i++) {
159 const float time = sortedTimes.at(i);
161 minTime = std::min(minTime, time);
162 maxTime = std::max(maxTime, time);
165 m_timeAverage =
float(totalTime / countAmount);
166 m_timeDeviation = maxTime - minTime;
167 Q_EMIT timeAverageChanged();
168 Q_EMIT timeDeviationChanged();
170 Q_EMIT timeChanged();
173void QQuick3DParticleSystemLogging::resetData()
179 m_timeAverage = 0.0f;
180 m_timeDeviation = 0.0f;
181 m_totalTimesList.clear();
182 Q_EMIT updatesChanged();
183 Q_EMIT particlesMaxChanged();
184 Q_EMIT particlesUsedChanged();
185 Q_EMIT timeChanged();
186 Q_EMIT timeAverageChanged();
187 Q_EMIT timeDeviationChanged();
Combined button and popup list for selecting options.