From 047f801078a52042ef02750b577233d115ed0f57 Mon Sep 17 00:00:00 2001 From: lichao <lichao@aiotlink.com> Date: 星期二, 13 四月 2021 17:12:25 +0800 Subject: [PATCH] rename library, add box. --- utest/speed_test.cpp | 16 ++++++++-------- 1 files changed, 8 insertions(+), 8 deletions(-) diff --git a/utest/speed_test.cpp b/utest/speed_test.cpp index b1f11ac..7f77b02 100644 --- a/utest/speed_test.cpp +++ b/utest/speed_test.cpp @@ -26,7 +26,7 @@ ShmRemover auto_remove(shm_name); const int mem_size = 1024 * 1024 * 50; MQId id = boost::uuids::random_generator()(); - const int timeout = 100; + const int timeout = 1000; const uint32_t data_size = 4000; const std::string proc_id = "demo_proc"; @@ -44,7 +44,6 @@ DEFER1(msg.Release(shm);); for (uint64_t i = 0; i < n; ++i) { - // mq.Send(id, str.data(), str.size(), timeout); mq.Send(id, msg, timeout); } }; @@ -91,6 +90,7 @@ www.Launch(Writer, i, nmsg); } www.WaitAll(); + printf("writer finished\n"); run.store(false); rrr.WaitAll(); printf("Write %ld msg R(%3d) W(%3d), : ", total_msg, nreader, nwriter); @@ -136,14 +136,18 @@ req_body.set_topic("topic"); req_body.set_data(msg_content); auto req_head(InitMsgHead(GetType(req_body), client_proc_id)); + req_head.add_route()->set_mq_id(&cli.id(), cli.id().size()); request_rc.MakeRC(shm, req_head, req_body); + DEFER1(request_rc.Release(shm)); MsgRequestTopic reply_body; reply_body.set_topic("topic"); reply_body.set_data(msg_content); auto reply_head(InitMsgHead(GetType(reply_body), server_proc_id)); + reply_head.add_route()->set_mq_id(&srv.id(), srv.id().size()); MsgI reply_rc; reply_rc.MakeRC(shm, reply_head, reply_body); + DEFER1(reply_rc.Release(shm)); std::atomic<uint64_t> count(0); @@ -167,7 +171,7 @@ } MsgI msg; BHMsgHead head; - if (!cli.SyncRecv(msg, head, 1000)) { + if (!cli.SyncRecv(msg, head, 100)) { printf("********** client recv error.\n"); } else { DEFER1(msg.Release(shm)); @@ -188,7 +192,7 @@ BHMsgHead req_head; while (!stop) { - if (srv.SyncRecv(req, req_head, 100)) { + if (srv.SyncRecv(req, req_head, 10)) { DEFER1(req.Release(shm)); if (req.ParseHead(req_head) && req_head.type() == kMsgTypeRequestTopic) { @@ -224,9 +228,5 @@ printf("request ok: %ld\n", count.load()); stop = true; servers.WaitAll(); - BOOST_CHECK(request_rc.IsCounted()); - BOOST_CHECK_EQUAL(request_rc.Count(), 1); - request_rc.Release(shm); - BOOST_CHECK(!request_rc.IsCounted()); // BOOST_CHECK_THROW(reply.Count(), int); } -- Gitblit v1.8.0