int main() { method1(); method2(); method3(); method4(); method5(); // On some platforms std::locale::classic() works // faster than std::locale() boost::iequals(str1, str2, std::locale::classic()); }
void FakeClassForNode::activeFunction(int id) { switch(id) { case 0: method1(); break; case 1: method2(0); break; case 2: method3(0,0); break; } }
int main(int argc, char **argv) { QCoreApplication app(argc, argv); if (!QDBusConnection::sessionBus().isConnected()) { fprintf(stderr, "Cannot connect to the D-Bus session bus.\n" "To start it, run:\n" "\teval `dbus-launch --auto-syntax`\n"); return 1; } method1(); method2(); method3(); return 0; }
gamete_pointer operator()( gamete_pointer base_gamete, gamete_pointer other_gamete, unsigned int gen = 0 ) { return method3( base_gamete, other_gamete, gen ); }
int main(int argc, char *argv[]) { //QCoreApplication a(argc, argv); srand(time(NULL)); long M=511; //number of channels long T=20; //convolution kernel size long N=5e9/(M*T); //number of timepoints double *Xin=(double *)malloc(sizeof(double)*M*N); double *Xout=(double *)malloc(sizeof(double)*M*N); double *Kern=(double *)malloc(sizeof(double)*T); printf("Note: Each operation consists of a multiply and an add.\n\n"); printf("Preparing...\n"); for (int ii=0; ii<M*N; ii++) { Xin[ii]=ii%183; } for (int t=0; t<T; t++) { Kern[t]=rand()*1.0/rand(); } if (1) { printf("\nMethod 1 (simple loops)...\n"); QTime timer; timer.start(); method1(M,N,T,Xin,Xout,Kern); double elapsed=timer.elapsed()*1.0/1000; printf("%g,%g,%g\n",Xout[1],Xout[1000],Xout[100000]); double mops=M*N*T/elapsed/1e6; printf("Method 1: Elapsed time: %.5f sec\n",elapsed); printf(" *** %g million operations per second ***\n\n",mops); } if (1) { printf("\nMethod 2 (simple loops - method 2)...\n"); QTime timer; timer.start(); method2(M,N,T,Xin,Xout,Kern); double elapsed=timer.elapsed()*1.0/1000; printf("%g,%g,%g\n",Xout[1],Xout[1000],Xout[100000]); double mops=M*N*T/elapsed/1e6; printf("Method 2: Elapsed time: %.5f sec\n",elapsed); printf(" *** %g million operations per second ***\n\n",mops); } if (1) { printf("\nMethod 3 (cblas level 1)...\n"); QTime timer; timer.start(); method3(M,N,T,Xin,Xout,Kern); double elapsed=timer.elapsed()*1.0/1000; printf("%g,%g,%g\n",Xout[1],Xout[1000],Xout[100000]); double mops=M*N*T/elapsed/1e6; printf("Method 3: Elapsed time: %.5f sec\n",elapsed); printf(" *** %g million operations per second ***\n\n",mops); } if (1) { printf("\nMethod 4 (cblas level 2)...\n"); QTime timer; timer.start(); method4(M,N,T,Xin,Xout,Kern); double elapsed=timer.elapsed()*1.0/1000; printf("%g,%g,%g\n",Xout[1],Xout[1000],Xout[100000]); double mops=M*N*T/elapsed/1e6; printf("Method 4: Elapsed time: %.5f sec\n",elapsed); printf(" *** %g million operations per second ***\n\n",mops); } if (1) { printf("\nMethod 5 (cblas level 2, multiple threads)...\n"); QTime timer; timer.start(); method5(M,N,T,Xin,Xout,Kern); double elapsed=timer.elapsed()*1.0/1000; printf("%g,%g,%g\n",Xout[1],Xout[1000],Xout[100000]); double mops=M*N*T/elapsed/1e6; printf("Method 5: Elapsed time: %.5f sec\n",elapsed); printf(" *** %g million operations per second ***\n\n",mops); } free(Xin); free(Xout); free(Kern); return 0; }
int main(){ int i=0; FILE *fp_in; FILE* fp_out; fp_in = fopen(FILE_NAME, "r"); fp_out = fopen("answers.txt", "w"); /***************************************************/ //Count how many integers in each array int input; int count[FILE_LINES]; int cnt=0; while(cnt<FILE_LINES) { input=0; count[cnt]=1; if ( (input = fgetc(fp_in)) == '[' ) { while ( (input = fgetc(fp_in)) != ']' ) { if(input == ',') count[cnt]++; } // printf("count[%d] = %d\n",cnt,count[cnt]); cnt++; } } fclose(fp_in); /***************************************************/ fp_in = fopen(FILE_NAME, "r"); //read file into array if (fp_in == NULL) { printf("Error Reading File\n"); exit (0); } const char delima[3] = "[,]"; int token=0; char line[LINE_SIZE]={0}; for(cnt=0;cnt<FILE_LINES;cnt++) { if (fgets(line, LINE_SIZE, fp_in) == NULL) //get the next line printf("fgets break;\n"); int* test = malloc(sizeof(int) * count[cnt]); i=0; test[i] = strtol(strtok(line,delima),NULL,10); // printf("token[%d] = %d\n",i,test[i]); while(token != '\n') { i++; if(i==count[cnt]) break; test[i] = strtol(strtok(NULL,delima),NULL,10); // printf("token[%d] = %d\n",i,test[i]); } /***** At here we have the array in test[] and now we call the algorithm ******/ // printf("count[%d]=%d\n",cnt,count[cnt]); char* str = method3(test,count[cnt]); fputs(str,fp_out); free(str); /*********************** Done, go to the next set ****************************/ free(test); } fclose(fp_in); fclose(fp_out); return 0; }
int main() { method3(); return 0; }
void SVT_ThreadMother::run() { int counter=0; while(!mCore->mCoreExit) { counter++; SLEEP(200); // continue; SVT_NodePoolRef lazyDelete; mMutex.lock(); SVT_NodePoolRef waitpool=mNodePoolWaited; mNodePoolWaited=NULL; mMutex.unlock(); if(!waitpool.isNull() && mNodePool!=waitpool) { // wantStart=true; if(!mNodePool.isNull()) { mNodePool->mPoolExit=true; mNodePool->stop(); } waitpool->mPoolExit=true; waitpool->stop(); mThreadPool.waitForDone(); lazyDelete=mNodePool; mNodePool=waitpool; CORE_LOCK(); #if USE_NETBIOS_METHOD if(sMapFlags &MF_USE_NETBIOS_SCAN) { SVT_TopoMethodRef method1(new SVT_NetbiosMethod(mNodePool.asPointer())); mNodePool->addMethod(method1); } #endif if(sMapFlags & MF_USE_ARP_SCAN) { SVT_TopoMethodRef method2(new SVT_NetscanMethod(mNodePool.asPointer())); mNodePool->addMethod(method2); } #if USE_UPNP_METHOD if(sMapFlags & MF_USE_UPNP_SCAN) { SVT_TopoMethodRef method3(new SVT_UpnpMethod(mNodePool.asPointer())); mNodePool->addMethod(method3); } #endif #if USE_NETGEARSPECIFIC_METHOD if(sMapFlags & MF_USE_NETGEARSPECIFIC_SCAN) { SVT_TopoMethodRef method4(new SVT_NetgearSpecificMethod(mNodePool.asPointer())); mNodePool->addMethod(method4); } #endif #if USE_AFP_METHOD if(sMapFlags & MF_USE_AFP_SCAN) { SVT_TopoMethodRef method5(new SVT_AfpMethod(mNodePool.asPointer())); mNodePool->addMethod(method5); } #endif #ifdef USE_RDP if(sMapFlags & MF_USE_RDP_SCAN) { SVT_TopoMethodRef method6(new SVT_RdpMethod(mNodePool.asPointer())); mNodePool->addMethod(method6); } #endif #ifdef USE_PUTTY if(sMapFlags & MF_USE_PUTTY_SCAN) { SVT_TopoMethodRef method7(new SVT_PuttyMethod(mNodePool.asPointer())); mNodePool->addMethod(method7); } #endif mNodePool->start(); CORE_UNLOCK(); } lazyDelete=NULL; } mMutex.lock(); if(!mNodePool.isNull()) { mNodePool->mPoolExit=true; } if(!mNodePoolWaited.isNull()) { mNodePoolWaited->mPoolExit=true; } mMutex.unlock(); mThreadPool.waitForDone(); }