CppBenchmark  1.0.4.0
C++ Benchmark Library
atomic.cpp

Atomic operations benchmark

//
// Created by Ivan Shynkarenka on 24.07.2015
//
#include <atomic>
template <typename T>
class AtomicFixture
{
protected:
std::atomic<T> x;
T y;
T z;
};
BENCHMARK_FIXTURE(AtomicFixture<int32_t>, "std::atomic<int32_t>.CAS()")
{
x.compare_exchange_strong(y, z, std::memory_order_acq_rel);
}
BENCHMARK_FIXTURE(AtomicFixture<int64_t>, "std::atomic<int64_t>.CAS()")
{
x.compare_exchange_strong(y, z, std::memory_order_acq_rel);
}
BENCHMARK_FIXTURE(AtomicFixture<int32_t>, "std::atomic<int32_t>.FAA()")
{
x.fetch_add(y, std::memory_order_acq_rel);
}
BENCHMARK_FIXTURE(AtomicFixture<int64_t>, "std::atomic<int64_t>.FAA()")
{
x.fetch_add(y, std::memory_order_acq_rel);
}
CppBenchmark definitions.
#define BENCHMARK_FIXTURE(fixture,...)
Benchmark with fixture register macro.
Definition: cppbenchmark.h:128
#define BENCHMARK_MAIN()
Benchmark main entry point macro.
Definition: cppbenchmark.h:46