コード例 #1
0
ファイル: retrieval-block.cpp プロジェクト: Adam57/SIGIR2016
void retrieval(char *indexPath,queryManager *queries,char *outputFile)
{
        IndexReader *theIndex = new IndexReader(indexPath);
        char blockInfoName[] = "BM25-02";
        theIndex -> loadBlockInfo(blockInfoName);

        ofstream F1;
        F1.open(outputFile);
        if(!F1) {cerr << "Error: file "<<outputFile<<" Could not be writ to"<<endl; return;}

        double totalEval=0;
        TimeCounter *timer = new TimeCounter();
        unsigned i;
        for(i=0;i<queries->num();i++)
        {
                timer->start();
                query* qry = queries -> getQuery(i);
                RetManager *reter = new RetManager(theIndex,qry);
                reter->retrieval(RetNum);
                timer->stop();
                cout<<qry->topicNum<<'\t'<<timer->getTrackTime()<<'\t'<<reter->getEvalCounter()<<endl;
                totalEval+=reter->getEvalCounter();
                reter->show(F1);
                //cout<<"\r retrieval topic "<<qry->topicNum<<flush;
                delete reter;
        }
        cout<<endl;
        cout<<"Used total time "<<timer->getTotalTime()<<"ms, average "<<timer->getAverageTime()<<"ms"<<" with "<<totalEval/queries->num()<<" evaluateions"<<endl;
        F1.close();
        delete(theIndex);
        delete(timer);
}
コード例 #2
0
ファイル: net_test.cpp プロジェクト: zheng39562/common
	void doPerformance(const string &arg){
		if(arg == ARG_CLIENT){
			bool bRet = net_connect(g_IP, TEST_CONNECT_PORT);
			if(!bRet){ DEBUG_E("client 连接失败。"); }

			PackerPtr pPacker(new Packer(NULL));
			pPacker->setBuffer(g_TestContext_1.c_str(), g_TestContext_1.size());

			long times(PERFROMANCE_TIMES);
			while(times--){
				net_sendAll_C(pPacker);
				usleep(1);
			}

			sleep(100);
		}
		if(arg == ARG_SERVER){
			TimeCounter timeCount;

			bool bRet = net_listen(g_IP, TEST_LISTEN_PORT);
			if(!bRet){ DEBUG_E("server 监听失败。"); }

			PackerPtr pPacker;

			long times(PERFROMANCE_TIMES);

			bool bNotFull(true);

			timeCount.start();
			while(bRet && times>0){
				if(net_recv_S(pPacker)){
					if(g_TestContext_1 == string((char*)pPacker->getBuffer(), pPacker->getBufferSize())){
						cout << --times << endl; 
					}
					else{
						bNotFull = false;
						DEBUG_E("接收数据出错。" << string((char*)pPacker->getBuffer(), pPacker->getBufferSize()));
						break;
					}
					if(!bNotFull){
						cout << "有数据丢失" << endl;
					}
				}
			}
			timeCount.stop();

			cout << "发送[" << PERFROMANCE_TIMES << "] use time [" << timeCount.getSecTimeD() << "]s" << endl;
		}
	}