mirror of
https://github.com/google/benchmark.git
synced 2025-01-30 22:00:16 +08:00
0526755944
* Add C++11 Ranged For loop alternative to KeepRunning As pointed out by @astrelni and @dominichamon, the KeepRunning loop requires a bunch of memory loads and stores every iterations, which affects the measurements. The main reason for these additional loads and stores is that the State object is passed in by reference, making its contents externally visible memory, and the compiler doesn't know it hasn't been changed by non-visible code. It's also possible the large size of the State struct is hindering optimizations. This patch allows the `State` object to be iterated over using a range-based for loop. Example: void BM_Foo(benchmark::State& state) { for (auto _ : state) { [...] } } This formulation is much more efficient, because the variable counting the loop index is stored in the iterator produced by `State::begin()`, which itself is stored in function-local memory and therefore not accessible by code outside of the function. Therefore the compiler knows the iterator hasn't been changed every iteration. This initial patch and idea was from Alex Strelnikov. * Fix null pointer initialization in C++03 |
||
---|---|---|
.. | ||
basic_test.cc | ||
benchmark_test.cc | ||
CMakeLists.txt | ||
complexity_test.cc | ||
cxx03_test.cc | ||
diagnostics_test.cc | ||
donotoptimize_test.cc | ||
filter_test.cc | ||
fixture_test.cc | ||
map_test.cc | ||
multiple_ranges_test.cc | ||
options_test.cc | ||
output_test_helper.cc | ||
output_test.h | ||
register_benchmark_test.cc | ||
reporter_output_test.cc | ||
skip_with_error_test.cc | ||
templated_fixture_test.cc | ||
user_counters_tabular_test.cc | ||
user_counters_test.cc |