From cf36ad55f7e30f048769ac18e296a5947ba99b34 Mon Sep 17 00:00:00 2001 From: Determinant Date: Sat, 6 Apr 2019 01:14:22 -0400 Subject: ... --- test/test_queue.cpp | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) (limited to 'test') diff --git a/test/test_queue.cpp b/test/test_queue.cpp index 5c56585..fac3bc7 100644 --- a/test/test_queue.cpp +++ b/test/test_queue.cpp @@ -43,7 +43,7 @@ void test_mpsc(int nproducers, int nops, size_t burst_size) { for (int j = 0; j < nops; j++) { //usleep(rand() / double(RAND_MAX) * 100); - while (!q.try_enqueue(x)) + while (!q.enqueue(x, false)) std::this_thread::yield(); x += nproducers; } @@ -55,7 +55,7 @@ void test_mpsc(int nproducers, int nops, size_t burst_size) { SALTICIDAE_LOG_INFO("consumers terminate"); } -/*void test_mpmc(int nproducers, int nconsumers, int nops, size_t burst_size) { +void test_mpmc(int nproducers, int nconsumers, int nops, size_t burst_size) { size_t total = nproducers * nops; using queue_t = salticidae::MPMCQueueEventDriven; queue_t q; @@ -64,6 +64,7 @@ void test_mpsc(int nproducers, int nops, size_t burst_size) { std::vector ecs; std::atomic collected(0); ecs.resize(nconsumers); + q.set_capacity(65536 * nproducers); for (int i = 0; i < nconsumers; i++) { q.reg_handler(ecs[i], [&collected, burst_size](queue_t &q) { @@ -98,7 +99,8 @@ void test_mpsc(int nproducers, int nops, size_t burst_size) { for (int j = 0; j < nops; j++) { //usleep(rand() / double(RAND_MAX) * 100); - q.try_enqueue(x); + while (!q.enqueue(x, false)) + std::this_thread::yield(); x += nproducers; } })); @@ -108,7 +110,6 @@ void test_mpsc(int nproducers, int nops, size_t burst_size) { for (auto &t: consumers) t.join(); SALTICIDAE_LOG_INFO("consumers terminate"); } -*/ int main(int argc, char **argv) { Config config; @@ -140,8 +141,8 @@ int main(int argc, char **argv) { else { SALTICIDAE_LOG_INFO("testing an MPMC queue..."); - //test_mpmc(opt_nproducers->get(), opt_nconsumers->get(), - // opt_nops->get(), opt_burst_size->get()); + test_mpmc(opt_nproducers->get(), opt_nconsumers->get(), + opt_nops->get(), opt_burst_size->get()); } return 0; } -- cgit v1.2.3-70-g09d2