fairness  v1.0.0
A collection of advanced syncronization mechanisms.
Loading...
Searching...
No Matches
priority_mutex_benchmark.hpp
Go to the documentation of this file.
1
14#include <boost/fairness.hpp>
16#include "../utils/thread_utils.hpp"
17
21
22 void lock_unlock_benchmark(benchmark::State& state) {
23 for (auto _ : state){
24 m.lock();
25 m.unlock();
26 }
27 }
28
29 void pipeline_benchmark_long(benchmark::State& state) {// order of 1/10th of a second (PM faster)
30 std::array<int, 8> prios {0, 1, 2, 1, 3, 2, 2, 0};
31 std::array<int, 8> preCT {20, 15, 20, 30, 10, 5, 5, 20};
32 int CT = 10;
33 std::array<int, 8> postCT {50, 30, 20, 25, 10, 15, 15, 45};
34
35 for (auto _ : state) {
36 utils::thread::thread_function<utils::thread::LockLevel::Unique, utils::waiting::WaitingLevel::Milli>(m, preCT[state.thread_index()], CT, postCT[state.thread_index()], prios[state.thread_index()]);
37 }
38 }
39
40 void pipeline_benchmark_gaming(benchmark::State& state) {// order of 10 to 15 milliseconds (PM faster)
41 std::array<int, 8> prios {0, 1, 2, 1, 3, 2, 2, 0};
42 std::array<int, 8> preCT {2000, 1500, 2000, 3000, 1000, 500, 500, 2000};
43 int CT = 1000;
44 std::array<int, 8> postCT {5000, 3000, 2000, 2500, 1000, 1500, 1500, 4500};
45
46 for (auto _ : state) {
47 utils::thread::thread_function<utils::thread::LockLevel::Unique, utils::waiting::WaitingLevel::Micro>(m, preCT[state.thread_index()], CT, postCT[state.thread_index()], prios[state.thread_index()]);
48 }
49 }
50
51 void pipeline_benchmark_audio(benchmark::State& state) {// order of 1 to 1.5 millisec (PM faster)
52 std::array<int, 8> prios {0, 1, 2, 1, 3, 2, 2, 0};
53 std::array<int, 8> preCT {200, 150, 200, 300, 100, 50, 50, 200};
54 int CT = 100;
55 std::array<int, 8> postCT {500, 300, 200, 250, 100, 150, 150, 450};
56
57 for (auto _ : state) {
58 utils::thread::thread_function<utils::thread::LockLevel::Unique, utils::waiting::WaitingLevel::Micro>(m, preCT[state.thread_index()], CT, postCT[state.thread_index()], prios[state.thread_index()]);
59 }
60 }
61
62 void pipeline_benchmark_fast(benchmark::State& state) {
63 std::array<int, 8> prios {0, 1, 2, 1, 3, 2, 2, 0};
64 std::array<int, 8> preCT {2000, 1500, 2000, 3000, 1000, 500, 500, 2000};
65 int CT = 1000;
66 std::array<int, 8> postCT {5000, 3000, 2000, 2500, 1000, 1500, 1500, 4500};
67
68 for (auto _ : state) {
69 utils::thread::thread_function<utils::thread::LockLevel::Unique, utils::waiting::WaitingLevel::Nano>(m, preCT[state.thread_index()], CT, postCT[state.thread_index()], prios[state.thread_index()]);
70 }
71 }
72}
Definition pqspinlock.hpp:25
void lock(Priority_t const priority=0)
Definition pqspinlock.hpp:49
The priority_mutex is an advanced synchronization mechanism that enhances the traditional mutex by in...
Definition priority_mutex_cpl.hpp:47
This file contains the all the includes required by the library.
Definition priority_mutex_benchmark.hpp:18
void pipeline_benchmark_fast(benchmark::State &state)
Definition priority_mutex_benchmark.hpp:62
void pipeline_benchmark_audio(benchmark::State &state)
Definition priority_mutex_benchmark.hpp:51
void pipeline_benchmark_long(benchmark::State &state)
Definition priority_mutex_benchmark.hpp:29
void pipeline_benchmark_gaming(benchmark::State &state)
Definition priority_mutex_benchmark.hpp:40
void lock_unlock_benchmark(benchmark::State &state)
Definition priority_mutex_benchmark.hpp:22
boost::fairness::priority_mutex< 4 > m
Definition priority_mutex_benchmark.hpp:19
boost::fairness::detail::pqspinlock pqspinlock
Definition priority_mutex_benchmark.hpp:20
void thread_function(Lockable &lockable, int preCriticalTime, int criticalTime, int postCriticalTime, int p=0)
Definition thread_utils.hpp:26
This file contains the implementation of a priority qlock.