in BenchmarkNdkSample/benchmark/cpp/benchmark/SampleBenchmarks.cpp [47:62]
static void BM_memcpy(benchmark::State& state) {
char* src = new char[state.range(0)];
char* dst = new char[state.range(0)];
memset(src, 'x', (size_t) state.range(0));
while (state.KeepRunning()) {
memcpy(dst, src, (size_t) state.range(0));
// DoNotOptimize is needed to prevent the compiler from optimizing away the memcpy()
// Comment out this line to see the benchmark result (incorrectly) go to near 0!
::benchmark::DoNotOptimize(dst);
}
state.SetBytesProcessed(
int64_t(state.iterations()) * int64_t(state.range(0)));
delete[] src;
delete[] dst;
}