From ccb6c89435ee7fd28dac497c5527f36abb709dc4 Mon Sep 17 00:00:00 2001 From: KRM7 <70973547+KRM7@users.noreply.github.com> Date: Sun, 3 Sep 2023 15:38:31 +0200 Subject: [PATCH] test --- test/integration/main.cpp | 97 +++++++++++++++++++++++++-------------- 1 file changed, 63 insertions(+), 34 deletions(-) diff --git a/test/integration/main.cpp b/test/integration/main.cpp index 47e4cea1..2998d888 100644 --- a/test/integration/main.cpp +++ b/test/integration/main.cpp @@ -7,41 +7,70 @@ #include "nsga2.hpp" #include "nsga3.hpp" +#include "utility/rcu.hpp" +#include +#include +#include + +detail::rcu_obj number = 0; + int main() { + std::jthread reader{ [&] { + while (true) + { + std::scoped_lock _{ number }; + int& tmp = number.get(); + std::atomic_thread_fence(std::memory_order_seq_cst); + std::this_thread::sleep_for(std::chrono::milliseconds{ 2 }); + std::atomic_thread_fence(std::memory_order_seq_cst); + std::cout << tmp << "\n"; + assert(0 <= tmp && tmp <= 100); + } + } }; + + std::jthread writer1{ [&] { + while (true) number = rng::randomInt(0, 100); + } }; + + std::jthread writer2{ [&] { + while (true) number = rng::randomInt(0, 100); + } }; + + //while (true) - { - binary_sphere(); - binary_rastrigin(); - binary_rosenbrock(); - binary_schwefel(); - binary_griewank(); - binary_ackley(); - binary_levy(); - - real_sphere(); - real_rastrigin(); - real_rosenbrock(); - real_schwefel(); - real_griewank(); - real_ackley(); - real_levy(); - - perm_tsp52(); - perm_tsp76(); - perm_tsp124(); - perm_tsp152(); - perm_tsp226(); - perm_tsp299(); - perm_tsp439(); - - integer_hello(); - integer_sentence(); - - benchmark_nsga2_zdt(); - benchmark_nsga2_dtlz(); - - benchmark_nsga3_zdt(); - benchmark_nsga3_dtlz(); - } + //{ + // binary_sphere(); + // //binary_rastrigin(); + // //binary_rosenbrock(); + // //binary_schwefel(); + // //binary_griewank(); + // //binary_ackley(); + // //binary_levy(); + + // //real_sphere(); + // //real_rastrigin(); + // //real_rosenbrock(); + // //real_schwefel(); + // //real_griewank(); + // //real_ackley(); + // //real_levy(); + + // //perm_tsp52(); + // //perm_tsp76(); + // //perm_tsp124(); + // //perm_tsp152(); + // //perm_tsp226(); + // //perm_tsp299(); + // //perm_tsp439(); + + // //integer_hello(); + // //integer_sentence(); + + // //benchmark_nsga2_zdt(); + // //benchmark_nsga2_dtlz(); + + // //benchmark_nsga3_zdt(); + // //benchmark_nsga3_dtlz(); + //} } \ No newline at end of file