Added some queue related benchmarks.

This commit is contained in:
Pedro Pinto committed 2018-10-23 15:04:58 +00:00
1 parent 37f3550831
commit be33ecc798
1 file changed
+26 -12
+26 -12
View File
@@ -28,7 +28,9 @@
#include <cstdlib>
#include <iostream>
#include <moodycamel/concurrentqueue.h>
#include <moodycamel/readerwriterqueue.h>
#include <mutex>
#include <tbb/concurrent_queue.h>
namespace bts {
@@ -444,18 +446,6 @@ static void tbb_concurrent_queue(benchmark::State &state) {
}
BENCHMARK(tbb_concurrent_queue);
static void moody_camel_queue(benchmark::State &state) {
using Q = moodycamel::ConcurrentQueue<void *>;
Q queue(1000000);
for (auto _ : state) {
void *result;
void *arg = &queue;
queue.enqueue(arg); // NOLINT
benchmark::DoNotOptimize(queue.try_dequeue(result));
}
}
BENCHMARK(moody_camel_queue);
static void boost_spsc(benchmark::State &state) {
boost::lockfree::spsc_queue<int> q(10000);
@@ -658,6 +648,30 @@ static void same_thread_mpmc_spdlog(benchmark::State &state) {
}
BENCHMARK(same_thread_mpmc_spdlog);
static void moodycamel_concurrent_queue(benchmark::State &state) {
using Q = moodycamel::ConcurrentQueue<int>;
Q queue(8);
int i = 0;
for (auto _ : state) {
queue.enqueue(++i); // NOLINT
benchmark::DoNotOptimize(queue.try_dequeue(i));
}
}
BENCHMARK(moodycamel_concurrent_queue);
static void moodycamel_spsc_queue(benchmark::State &state) {
using Queue = moodycamel::ReaderWriterQueue<int>;
Queue q1(8);
int i = 0;
for (auto _ : state) {
q1.enqueue(++i);
benchmark::DoNotOptimize(q1.try_dequeue(i));
}
}
BENCHMARK(moodycamel_spsc_queue);
std::string Benchmark::help() {
return "Run micro-benchmarks. Use --benchmark_filter=regex to run only "
"specific benchmarks.";