1#include "benchmark/benchmark.h" 2 3#include <cstdint> 4 5namespace { 6#if defined(__GNUC__) 7std::uint64_t double_up(const std::uint64_t x) __attribute__((const)); 8#endif 9std::uint64_t double_up(const std::uint64_t x) { return x * 2; } 10} 11 12int main(int, char*[]) { 13 // this test verifies compilation of DoNotOptimize() for some types 14 15 char buffer8[8]; 16 benchmark::DoNotOptimize(buffer8); 17 18 char buffer20[20]; 19 benchmark::DoNotOptimize(buffer20); 20 21 char buffer1024[1024]; 22 benchmark::DoNotOptimize(buffer1024); 23 benchmark::DoNotOptimize(&buffer1024[0]); 24 25 int x = 123; 26 benchmark::DoNotOptimize(x); 27 benchmark::DoNotOptimize(&x); 28 benchmark::DoNotOptimize(x += 42); 29 30 benchmark::DoNotOptimize(double_up(x)); 31 32 return 0; 33} 34