fairness  v1.0.0
A collection of advanced syncronization mechanisms.
Loading...
Searching...
No Matches
standard_mutex_benchmark.hpp
Go to the documentation of this file.
1
14#include <mutex>
15#include "../utils/thread_utils.hpp"
16
18 std::mutex m;
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) {
28 std::array<int, 8> preCT {20, 15, 20, 30, 10, 5, 5, 20};
29 int CT = 10;
30 std::array<int, 8> postCT {50, 30, 20, 25, 10, 15, 15, 45};
31
32 for (auto _ : state) {
33 utils::thread::thread_function<utils::thread::LockLevel::Unique, utils::waiting::WaitingLevel::Milli>(m, preCT[state.thread_index()], CT, postCT[state.thread_index()]);
34 }
35 }
36
37 void pipeline_benchmark_gaming(benchmark::State& state) {
38 std::array<int, 8> preCT {2000, 1500, 2000, 3000, 1000, 500, 500, 2000};
39 int CT = 1000;
40 std::array<int, 8> postCT {5000, 3000, 2000, 2500, 1000, 1500, 1500, 4500};
41
42 for (auto _ : state) {
43 utils::thread::thread_function<utils::thread::LockLevel::Unique, utils::waiting::WaitingLevel::Micro>(m, preCT[state.thread_index()], CT, postCT[state.thread_index()]);
44 }
45 }
46
47 void pipeline_benchmark_audio(benchmark::State& state) {
48 std::array<int, 8> prios {0, 1, 2, 1, 3, 2, 2, 0};
49 std::array<int, 8> preCT {200, 150, 200, 300, 100, 50, 50, 200};
50 int CT = 100;
51 std::array<int, 8> postCT {500, 300, 200, 250, 100, 150, 150, 450};
52
53 for (auto _ : state) {
54 utils::thread::thread_function<utils::thread::LockLevel::Unique, utils::waiting::WaitingLevel::Micro>(m, preCT[state.thread_index()], CT, postCT[state.thread_index()]);
55 }
56 }
57
58 void pipeline_benchmark_fast(benchmark::State& state) { /* */
59 std::array<int, 8> prios {0, 1, 2, 1, 3, 2, 2, 0};
60 std::array<int, 8> preCT {2000, 1500, 2000, 3000, 1000, 500, 500, 2000};
61 int CT = 1000;
62 std::array<int, 8> postCT {5000, 3000, 2000, 2500, 1000, 1500, 1500, 4500};
63
64 for (auto _ : state) {
65 utils::thread::thread_function<utils::thread::LockLevel::Unique, utils::waiting::WaitingLevel::Nano>(m, preCT[state.thread_index()], CT, postCT[state.thread_index()]);
66 }
67 }
68}
Definition standard_mutex_benchmark.hpp:17
void lock_unlock_benchmark(benchmark::State &state)
Definition standard_mutex_benchmark.hpp:20
void pipeline_benchmark_fast(benchmark::State &state)
Definition standard_mutex_benchmark.hpp:58
void pipeline_benchmark_gaming(benchmark::State &state)
Definition standard_mutex_benchmark.hpp:37
void pipeline_benchmark_long(benchmark::State &state)
Definition standard_mutex_benchmark.hpp:27
void pipeline_benchmark_audio(benchmark::State &state)
Definition standard_mutex_benchmark.hpp:47
std::mutex m
Definition standard_mutex_benchmark.hpp:18
void thread_function(Lockable &lockable, int preCriticalTime, int criticalTime, int postCriticalTime, int p=0)
Definition thread_utils.hpp:26