-
-
Save heatd/f0f24a2b207118b193ff682d3ee4d901 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> | |
static void mfence_bench(benchmark::State& state) | |
{ | |
for (auto _ : state) { | |
__asm__ __volatile__("mfence" ::: "memory"); | |
} | |
} | |
static void add_stack(benchmark::State& state) | |
{ | |
for (auto _ : state) { | |
__asm__ __volatile__("lock addq $0, (%%rsp)" ::: "memory"); | |
} | |
} | |
static unsigned long shite_global; | |
static void add_global(benchmark::State& state) | |
{ | |
for (auto _ : state) { | |
__asm__ __volatile__("lock addq $0, %0" :: "m"(shite_global) : "memory"); | |
} | |
} | |
BENCHMARK(mfence_bench); | |
BENCHMARK(add_stack); | |
BENCHMARK(add_global); | |
BENCHMARK_MAIN(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment