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