Alternate positions when profiling a graph to avoid XYZ optimization bias

This commit is contained in:
Marc Gilleron 2020-07-11 16:57:41 +01:00
parent 1cd0a491bb
commit 72c970e182

View File

@ -466,14 +466,20 @@ void VoxelGeneratorGraph::load_graph_from_variant_data(Dictionary data) {
// Debug land // Debug land
float VoxelGeneratorGraph::debug_measure_microseconds_per_voxel() { float VoxelGeneratorGraph::debug_measure_microseconds_per_voxel() {
Vector3i pos(1, 1, 1); // Need to query varying positions to avoid some optimizations to kick in
FixedArray<Vector3i, 2> random_positions;
random_positions[0] = Vector3i(1, 1, 1);
random_positions[1] = Vector3i(2, 2, 2);
float v; float v;
const uint32_t iterations = 1000000; const uint32_t iterations = 1000000;
ProfilingClock profiling_clock; ProfilingClock profiling_clock;
profiling_clock.restart(); profiling_clock.restart();
for (uint32_t i = 0; i < iterations; ++i) { for (uint32_t i = 0; i < iterations; ++i) {
v = generate_single(pos); v = generate_single(random_positions[i & 1]);
} }
uint64_t ius = profiling_clock.restart(); uint64_t ius = profiling_clock.restart();
float us = static_cast<double>(ius) / iterations; float us = static_cast<double>(ius) / iterations;
// print_line(String("Time: {0}us").format(varray(us))); // print_line(String("Time: {0}us").format(varray(us)));