forked from CharlesFrasch/cppcon2023
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbench_all.cpp
More file actions
64 lines (51 loc) · 2.04 KB
/
bench_all.cpp
File metadata and controls
64 lines (51 loc) · 2.04 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
#include "Fifo2.hpp"
#include "Fifo3.hpp"
#include "Fifo3a.hpp"
#include "Fifo4.hpp"
#include "Fifo4a.hpp"
#include "Fifo4b.hpp"
#include "Fifo5.hpp"
#include "Fifo5a.hpp"
#include "Fifo5b.hpp"
#include "Mutex.hpp"
#include "rigtorp.hpp"
#include <boost/lockfree/spsc_queue.hpp> // boost 1.74.0
#include "bench.hpp"
#include <iostream>
template<typename ValueT>
struct isRigtorp<rigtorp::SPSCQueue<ValueT>> : std::true_type {};
// Configuring fixed size to match Fifo5's fixed size
template<typename T>
using boost_spsc_queue = boost::lockfree::spsc_queue<T, boost::lockfree::fixed_sized<true>>;
template<typename ValueT>
void once(long iters, int cpu1, int cpu2) {
std::cout <<
// Bench<Fifo2<ValueT>>{}(iters, cpu1, cpu2) << "," <<
// Bench<Mutex<ValueT>>{}(iters, cpu1, cpu2) <<
Bench<Fifo3<ValueT>>{}(iters, cpu1, cpu2) << "," << std::flush <<
Bench<Fifo3a<ValueT>>{}(iters, cpu1, cpu2) << "," << std::flush <<
Bench<Fifo4<ValueT>>{}(iters, cpu1, cpu2) << "," << std::flush <<
Bench<Fifo4a<ValueT>>{}(iters, cpu1, cpu2) << "," << std::flush <<
Bench<Fifo4b<ValueT>>{}(iters, cpu1, cpu2) << "," << std::flush <<
Bench<Fifo5<ValueT>>{}(iters, cpu1, cpu2) << "," << std::flush <<
Bench<Fifo5a<ValueT>>{}(iters, cpu1, cpu2) << "," << std::flush <<
Bench<Fifo5b<ValueT>>{}(iters, cpu1, cpu2) << "," << std::flush <<
Bench<rigtorp::SPSCQueue<ValueT>>{}(iters, cpu1, cpu2) << "," << std::flush <<
Bench<boost_spsc_queue<ValueT>>{}(iters, cpu1, cpu2) << std::flush <<
"\n";
}
int main(int argc, char* argv[]) {
constexpr auto cpu1 = 1;
constexpr auto cpu2 = 2;
constexpr auto iters = 400'000'000l;
auto reps = 10;
if (argc == 2) {
reps = std::atoi(argv[1]);
}
using value_type = std::int64_t;
std::cout << "Fifo3,Fifo3a,Fifo4,Fifo4a,Fifo4b,Fifo5,Fifo5a,Fifo5b,rigtorp,boost_spsc_queue" << std::endl;
// std::cout << "Fifo2,Mutex\n";
for (auto rep = 0; rep < reps; ++rep) {
once<value_type>(iters, cpu1, cpu2);
}
}