void LightbenchManager::startBench(const std::string& data, int totalReqNum) { totalReqNum_ = totalReqNum; ThreadVector threadList; int passBeginTime = getCurrentTimeUsec(); for (int i = 0; i < coreNum_; i++) { boost::function<void ()> func = boost::bind(&LightbenchManager::benchmark, this, getSplitReqNum(i, totalReqNum, coreNum_), data); std::shared_ptr<muduo::Thread> thread(new muduo::Thread(func)); threadList.push_back(thread); thread->start(); } std::cout << "benchmark start!" << std::endl; std::cout << std::endl; for (auto thread : threadList) { thread->join(); } int passEndTime = getCurrentTimeUsec(); totalPassTime_ = passEndTime - passBeginTime; }
static void StartThread(void *(*start_routine)(void*), C *arg) { pthread_t * t = new pthread_t; _threads.push_back(t); pthread_create(t, NULL, start_routine, reinterpret_cast<void*>(arg)); }