-
-
Save RecursiveG/5361f6da8814f3f11bb63581f401cd87 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <benchmark/benchmark.h> | |
// ---------------------------------------------------------- | |
// Benchmark Time CPU Iterations | |
// ---------------------------------------------------------- | |
// BM_StaticFalse 0.228 ns 0.227 ns 1000000000 | |
// BM_StaticTrue 0.457 ns 0.456 ns 1000000000 | |
// BM_DynamicFalse 0.228 ns 0.228 ns 1000000000 | |
// BM_DynamicTrue 0.458 ns 0.457 ns 1000000000 | |
void func_static_false() { | |
benchmark::DoNotOptimize(42); | |
} | |
void func_static_true() { | |
benchmark::DoNotOptimize(42); | |
benchmark::DoNotOptimize(42); | |
} | |
void func_dynamic(bool val) { | |
if (val) { | |
benchmark::DoNotOptimize(42); | |
} | |
benchmark::DoNotOptimize(42); | |
} | |
static void BM_StaticFalse(benchmark::State& state) { | |
for (auto _ : state) { | |
func_static_false(); | |
} | |
} | |
BENCHMARK(BM_StaticFalse); | |
static void BM_StaticTrue(benchmark::State& state) { | |
for (auto _ : state) { | |
func_static_true(); | |
} | |
} | |
BENCHMARK(BM_StaticTrue); | |
static void BM_DynamicFalse(benchmark::State& state) { | |
for (auto _ : state) { | |
func_dynamic(false); | |
} | |
} | |
BENCHMARK(BM_DynamicFalse); | |
static void BM_DynamicTrue(benchmark::State& state) { | |
for (auto _ : state) { | |
func_dynamic(true); | |
} | |
} | |
BENCHMARK(BM_DynamicTrue); | |
BENCHMARK_MAIN(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment