I want to compare the performance of two algorithms on a large inputs. The primary difference between the algorithms is that one should have better cache access patterns than the other. I want the size of the input to be much larger than the L3 cache, so the input will exceed 64 MB.
The algorithms are implemented as func1
and func2
. I would implement the test as
std::vector<int> input_1 = GetRandomInput();
std::vector<int> input_2 = input_1;
double func1_runtime = Benchmark(func1, input_1);
std::cout << "func1s runtime was " << func1_runtime << "\n";
double func2_runtime = Benchmark(func2, input_2);
std::cout << "func2s runtime was " << func2_runtime << "\n";
I'm trying to find a function Benchmark
that will attempt to clear all of the data out of cache prior to running. Is there any such function in Google Benchmark?