#include <atomic>
#include <string>
#include "base/barrier_closure.h"
#include "base/functional/callback.h"
#include "base/memory/raw_ptr.h"
#include "base/synchronization/lock.h"
#include "base/synchronization/waitable_event.h"
#include "base/threading/simple_thread.h"
#include "testing/gtest/include/gtest/gtest.h"
#include "testing/perf/perf_result_reporter.h"
namespace base {
namespace {
constexpr char kMetricPrefixCounter[] = …;
constexpr char kMetricOperationThroughput[] = …;
constexpr uint64_t kNumIterations = …;
perf_test::PerfResultReporter SetUpReporter(const std::string& story_name) { … }
class Uint64_NoLock { … };
class Uint64_Lock { … };
class AtomicUint64_NoBarrier { … };
class AtomicUint64_Barrier { … };
template <typename CounterType>
class IncrementThread : public SimpleThread { … };
template <typename CounterType>
void RunIncrementPerfTest(const std::string& story_name, int num_threads) { … }
}
TEST(CounterPerfTest, Uint64_NoLock_1Thread) { … }
TEST(CounterPerfTest, Uint64_Lock_1Thread) { … }
TEST(CounterPerfTest, Uint64_Lock_4Threads) { … }
TEST(CounterPerfTest, AtomicUint64_NoBarrier_1Thread) { … }
TEST(CounterPerfTest, AtomicUint64_NoBarrier_4Threads) { … }
TEST(CounterPerfTest, AtomicUint64_Barrier_1Thread) { … }
TEST(CounterPerfTest, AtomicUint64_Barrier_4Threads) { … }
}