int main() { // variables para manejo de tiempo struct timeval start_ts; struct timeval stop_ts; struct timeval elapsed_time; int res; // variable de resultado de procesos char namedest[100]; // variable para el nombre del destino // obtener el tiempo inicial gettimeofday(&start_ts, NULL); // generar los nombres de los archivos fuente y destino strcpy(namedest, strtok(filename,".")); strcat(filename,".bmp"); strcat(namedest,"_secuencial.bmp"); printf("Archivo fuente %s\n",filename); printf("Archivo destino %s\n",namedest); // cargar el archivo en memoria res = loadBMP(filename, &imagenfte); // verificar el cargado if(res == -1) { fprintf(stderr, "Error al abrir imagen\n"); exit(1); } printf("Procesando imagen de: Renglones = %d, Columnas =%d\n", imagenfte.infoheader.rows, imagenfte.infoheader.cols); // ejecutar el procesamiento processBMP(&imagenfte, &imagendst); // res = saveBMP(namedest, &imagendst); // verificar la escritura if(res == -1) { fprintf(stderr, "Error al escribir imagen\n"); exit(1); } // obtener el tiempo final gettimeofday(&stop_ts, NULL); // calcular e imprimir tiempo timersub(&stop_ts, &start_ts, &elapsed_time); printf("------------------------------\n"); printf("TIEMPO TOTAL, %ld.%ld segundos\n",elapsed_time.tv_sec, elapsed_time.tv_usec); }
int main() { clock_t t_inicial,t_final; IMAGE imagefte;//Imagen fuente IMAGE imagedst;//Imagen destino //file name char namedest[80]; strcpy(namedest,strtok(filename,".")); strcat(filename,".bmp"); strcat(namedest,"_P.bmp"); printf("Source file: %s\n",filename); printf("Target file: %s\n",namedest); t_inicial=clock(); //load if(loadBMP(filename,&imagefte)==-1) { fprintf(stderr,"ERROR: Couldn't open image\n"); exit(1); } printf("\nProcessing image: ROWS= %d, COLUMNS= %d\n\n",imagefte.infoheader.rows,imagefte.infoheader.cols); //process processBMP(&imagefte,&imagedst); //save puts("Saving..."); if(saveBMP(namedest,&imagedst)==-1) { fprintf(stderr,"Error al escribir imagen\n"); exit(1); } t_final=clock(); printf("------------------------------\n"); printf("Tiempo %3.6f segundos\n",((float) t_final- (float)t_inicial)/ CLOCKS_PER_SEC); }
int main() { int res; long long start_ts; long long stop_ts; long long elapsed_time; struct timeval ts; gettimeofday(&ts, NULL); start_ts = ts.tv_sec * 1000000 + ts.tv_usec;//start time strcpy(namedest,strtok(filename,".")); strcat(filename,".bmp"); strcat(namedest,"_P.bmp"); printf("Archivo fuente %s\n",filename); printf("Archivo destino %s\n",namedest); res=loadBMP(filename,&imagenfte); if(res==-1) { fprintf(stderr,"Error al abrir imagen\n"); exit(1); } printf("Procesando imagen de: Renglones = %d, Columnas = %d\n",imagenfte.infoheader.rows,imagenfte.infoheader.cols); processBMP(&imagenfte,&imagendst); res=saveBMP(namedest,&imagendst); if(res==-1) { fprintf(stderr,"Error al escribir imagen\n"); exit(1); } gettimeofday(&ts, NULL); stop_ts = ts.tv_sec * 1000000 + ts.tv_usec; //end time elapsed_time = stop_ts - start_ts; printf("Tiempo = %4.2f segundos\n",(float)elapsed_time/1000000);//elapsed time }