void configInit() { initializeFrame(); initializeRenderer(); Window* window = static_cast< Window* >( _channel->getWindow( )); _glWidgetPtr->setGLContext( GLContextPtr( new EqContext( window ))); }
int main(int argc , char *argv[]){ int i; struct timeval tv; char nameOfAlgo[20]; unsigned int timeBeforeAlgo, timeAfterAlgo, timeBeforeOptimal, timeAfterOptimal, timeTakenByOptimal, timeTakenByAlgo; for (i=1; i < argc; i++){ if (strcmp(argv[i],"-h") == 0){ showHelp(); }else if (strcmp(argv[i],"-f") == 0){ availableFrames = framesLeft = atoi(argv[++i]); }else if (strcmp(argv[i],"-r") == 0){ strcpy(replacementPolicy,argv[++i]); }else if (strcmp(argv[i],"-i") == 0){ strcpy(fileName,argv[++i]); }else printf("%s is a wrong option. Please enter the correct option",argv[i]); } FILE *fp; if ((fp = fopen(fileName,"r")) != NULL){ int c; i = 0; while ((c = getc(fp)) != EOF){ if (isspace(c) == 0) inputSeq[i++] = c; } inputSeq[i] = '\0'; fclose(fp); } else{ printf("Enter the sequence!!\n"); fgets(inputSeq,sizeof inputSeq, stdin); } if (strcmp(replacementPolicy,"LFU") == 0){ strcpy(nameOfAlgo,"LFU"); gettimeofday(&tv, NULL); timeBeforeAlgo = (uint)tv.tv_usec; LFUPageReplacement(); gettimeofday(&tv, NULL); timeAfterAlgo = (uint)tv.tv_usec; timeTakenByAlgo = (uint) (timeAfterAlgo - timeBeforeAlgo); } else if (strcmp(replacementPolicy,"LRU-STACK") == 0){ strcpy(nameOfAlgo,"LRU-STACK"); gettimeofday(&tv, NULL); timeBeforeAlgo = (uint)tv.tv_usec; LRUStackPageReplacement(); gettimeofday(&tv, NULL); timeAfterAlgo = (uint)tv.tv_usec; timeTakenByAlgo = (uint) (timeAfterAlgo - timeBeforeAlgo); } else if (strcmp(replacementPolicy,"LRU-CLOCK") == 0){ strcpy(nameOfAlgo,"LRU-CLOCK"); gettimeofday(&tv, NULL); timeBeforeAlgo = (uint)tv.tv_usec; LRUClockPageReplacement(); gettimeofday(&tv, NULL); timeAfterAlgo = (uint)tv.tv_usec; timeTakenByAlgo = (uint) (timeAfterAlgo - timeBeforeAlgo); } else if (strcmp(replacementPolicy,"LRU-REF8") == 0){ strcpy(nameOfAlgo,"LRU-REF8"); gettimeofday(&tv, NULL); timeBeforeAlgo = (uint)tv.tv_usec; LRURefPageReplacement(); gettimeofday(&tv, NULL); timeAfterAlgo = (uint)tv.tv_usec; timeTakenByAlgo = (uint) (timeAfterAlgo - timeBeforeAlgo); } else{ strcpy(nameOfAlgo,"FIFO"); gettimeofday(&tv, NULL); timeBeforeAlgo = (uint)tv.tv_usec; initializeList(); initializeFrame(); FIFOPageReplacement(); gettimeofday(&tv, NULL); timeAfterAlgo = (uint)tv.tv_usec; timeTakenByAlgo = (uint) (timeAfterAlgo - timeBeforeAlgo); } timeBeforeOptimal = (uint)tv.tv_usec; initializeList(); initializeFrame(); OptimalPageReplacement(); timeAfterOptimal = (uint)tv.tv_usec; timeTakenByOptimal = (uint) (timeAfterOptimal - timeBeforeOptimal); float percentPage = ((nbOfPageReplacementByAlgo-nbOfPageReplacementByOptimal*1.00)/nbOfPageReplacementByOptimal)*100; float percentTime = ((timeAfterOptimal-timeTakenByAlgo*1.00)/timeAfterOptimal)*100; printf("Percentage page replacement penalty using %s \t: %2.2f percent\n\n",nameOfAlgo,percentPage); printf("Total time to run %s algorithm \t: %u microseconds\nTotal time to run Optimal algorithm \t: %u microseconds\n",nameOfAlgo,timeTakenByAlgo,timeAfterOptimal); printf("%s is %2.2f percent faster than Optimal algorithm.\n\n",nameOfAlgo,percentTime); if(nbOfPageReplacementByOptimal < 0) printf("!! Any negative value should be considered as 0.\n\n"); return 0; }
void DepthPipeline::computeImage() { initializeFrame(); Mat raw(240, 320, getSourceFormat(), temp); //medianBlur(raw, raw, 3); upscaleFrame(); }