Skip to content

Commit

Permalink
test
Browse files Browse the repository at this point in the history
  • Loading branch information
KRM7 committed Sep 3, 2023
1 parent d649785 commit ccb6c89
Showing 1 changed file with 63 additions and 34 deletions.
97 changes: 63 additions & 34 deletions test/integration/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -7,41 +7,70 @@
#include "nsga2.hpp"
#include "nsga3.hpp"

#include "utility/rcu.hpp"
#include <thread>
#include <iostream>
#include <chrono>

detail::rcu_obj<int> 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();
//}
}

0 comments on commit ccb6c89

Please sign in to comment.