MCPcopy Create free account
hub / github.com/TomClabault/HIPRT-Path-Tracer / recompute_data

Method recompute_data

src/UI/PerformanceMetricsComputer.cpp:193–233  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

191 recompute_data(new_size);
192
193 m_window_size = new_size;
194}
195
196void PerformanceMetricsComputer::resize_values_vectors(int new_size)
197{
198 for (auto& pair_kv : m_values)
199 // Resizing the values vectors.
200 // If resizing to a smaller size, .resize() throws away the elements at the end.
201 // If resizing to a greater size, .resize() inserts new element at the end.
202 // This is what we want.
203 pair_kv.second.resize(new_size, 0.0);
204}
205
206void PerformanceMetricsComputer::recompute_data(int new_size)
207{
208 // This function could be recomputing elements in a smarter way but because recompute_data
209 // isn't expected to be called that often at all, let's keep it simple
210
211 if (new_size > m_window_size)
212
213 // Nothing to recompute, new elements will be added later
214 return;
215
216 // Else, elements were removed from the end, we need to recompute the sum,
217 // sums of squares, ... without taking these removed elements into account
218
219 for (auto pair_kv : m_values)
220 {
221 const std::string& key = pair_kv.first;
222
223 if (m_values_count[key] < new_size)
224 {
225 // There wasn't enough values so resizing the vector didn't remove any value,
226 // nothing to recompute
227
228 continue;
229 }
230
231 m_values_count[key] = std::min(m_values_count[key], new_size);
232 m_values_sum[key] = 0.0;
233 m_values_sum_of_squares[key] = 0.0;
234 m_data_indices[key] = m_data_indices[key] > new_size ? 0 : m_data_indices[key];
235 m_min_max_data[key].clear();
236

Callers

nothing calls this directly

Calls 3

minFunction · 0.85
insertMethod · 0.80
clearMethod · 0.45

Tested by

no test coverage detected