bool LatencyTask::requestComplete(HttpClientConnection *conn) { auto p = current_request.find(conn->contents()); if (p == current_request.end()) { log() << "unexpected response: " << conn->contents(); } else { double latency = secondsSince(p->second); log() << "got " << conn->contents() << " after " << latency << " sec"; samples.push_back(latency); } if (samples.size() < 12) return true; if (!terminated()) { log() << "Samples: " << json11::Json(samples).dump(); setResult(calculateLatency(samples)); } return false; }
void runDefaultTests() { std::vector<DataDescriptor*> dataDescriptors = ioutil::createDataDescriptors(testlabSettings().datafile); std::vector<InitDescriptor*> initDescriptors = ioutil::createInitDescriptors(testlabSettings().initfile); std::vector<AlgoDescriptor*> algoDescriptors = ioutil::createAlgoDescriptors(testlabSettings().algofile); // loop over all data sets for (unsigned int dataIndex=0; dataIndex<dataDescriptors.size(); ++dataIndex) { // clear input input.weights.resize(0); input.points.resize(0,0); std::cout << ">" << std::endl << ">> retrieving new data set from descriptor: " << dataDescriptors[dataIndex]->tag() << std::endl << ">" << std::endl; // load or generate data from descriptor truth = dataDescriptors[dataIndex]->retrieve(input); if (input.weights.size()==0) { std::cout << " skipping empty data set." << std::endl << std::endl; continue; } idx_type n = input.points.cols(); idx_type d = input.points.rows(); // std::cout << std::endl; std::cout << "Using " << d << " dimensions of the " << n << " input points." << std::endl; // loop over all values of k for (DataDescriptor::kIterator kIter=dataDescriptors[dataIndex]->first_k(); kIter!=dataDescriptors[dataIndex]->last_k(); ++kIter) { unsigned int k = *kIter; std::cout << std::endl << "> computing solutions with k=" << k << std::endl << std::endl; std::stringstream outDirStream; outDirStream << testlabSettings().outputDir << "/" << dataDescriptors[dataIndex]->tag() << "_k" << k; // for average time stats double totalAlgotime = 0; unsigned int totalAlgoruns = 0; // loop over all initial solutions for (unsigned int initIndex=0; initIndex<initDescriptors.size(); ++initIndex) { std::cout << "computing initial solution from descriptor: " << initDescriptors[initIndex]->tag() << std::endl; clock_t t = clock(); GMMDesc initial = initDescriptors[initIndex]->compute(input, k); double inittime = secondsSince(t); std::cout << " computed in " << inittime << " seconds." << std::endl << std::endl; for (int algoIndex=0; algoIndex<algoDescriptors.size(); ++algoIndex) { std::stringstream outFileStream; outFileStream << initDescriptors[initIndex]->tag() << "__"; AlgoDescriptor* ad = algoDescriptors[algoIndex]; while (ad!=NULL) { outFileStream << ad->tag(); ad = ad->getNext(); if (ad!=NULL) outFileStream << "_and_"; } try { double algotime = runAlgoSequence(algoDescriptors[algoIndex], initial, inittime, outDirStream.str(), outFileStream.str()); totalAlgoruns++; totalAlgotime += algotime; } catch (std::exception& e) { std::cout << "runDefaultTests() - EXCEPTION CAUGHT!" << std::endl; std::cout << e.what() << std::endl; std::cout << "runDefaultTests() - Continuing with next algorithm sequence." << std::endl; ioutil::closeAllFiles(); } } } } } }
inline double BasicTimer::secondsSinceStart() const { return secondsSince( startTimeval ); }