| | |
| | | #include "center.h" |
| | | #include "defs.h" |
| | | #include "failed_msg.h" |
| | | #include "util.h" |
| | | #include <atomic> |
| | | #include <boost/uuid/uuid_generators.hpp> |
| | |
| | | static const bool value = true; |
| | | }; |
| | | |
| | | typedef FailedMsgQ ServerFailedQ; |
| | | |
| | | BOOST_AUTO_TEST_CASE(Temp) |
| | | { |
| | | const std::string shm_name("ShmTemp"); |
| | | ShmRemover auto_remove(shm_name); //remove twice? in case of killed? |
| | | SharedMemory shm(shm_name, 1024 * 1024 * 10); |
| | | |
| | | typedef std::chrono::steady_clock clock; |
| | | int n = 1000 * 1000; |
| | | std::vector<clock::time_point> tps(n); |
| | | { |
| | | printf("thread switch %d times, ", n); |
| | | boost::timer::auto_cpu_timer timer; |
| | | for (auto &tp : tps) { |
| | | tp = clock::now(); |
| | | std::this_thread::yield(); |
| | | } |
| | | } |
| | | printf("time: %ld ns\n", (tps.back() - tps.front()).count()); |
| | | return; |
| | | // sub topic partial match. |
| | | Topic topics[] = { |
| | | "", |
| | | ".", |
| | |
| | | |
| | | bool r = provider.Publish(topic, data.data(), data.size(), timeout); |
| | | if (!r) { |
| | | printf("pub ret: %s\n", r ? "ok" : "fail"); |
| | | static std::atomic<int> an(0); |
| | | int n = ++an; |
| | | printf("pub %d ret: %s\n", n, r ? "ok" : "fail"); |
| | | } |
| | | } |
| | | }; |
| | |
| | | topics.push_back("t" + std::to_string(i)); |
| | | } |
| | | Topics part; |
| | | boost::timer::auto_cpu_timer pubsub_timer; |
| | | for (size_t i = 0; i < topics.size(); ++i) { |
| | | part.push_back(topics[i]); |
| | | threads.Launch(Sub, i, topics); |