int main(int argc, char* argv[]) { BMP img; // Variables para controlar el tiempo double usrtime11, systime11, walltime11, usrtime21, systime21, walltime21, real, user, sys, cpuwall; char IMAGEN[55]; char IMAGEN_OUT[55]; char tipoEjecucion = 'C'; if(argc < 3){ exit(1); } if(argc == 4){ // Obtenemos el tipo de ejecución tipoEjecucion = argv[3][0]; } strcpy(IMAGEN, argv[1]); strcpy(IMAGEN_OUT, argv[2]); abrirImagen(&img, IMAGEN); uswtime(&usrtime11, &systime11, &walltime11); if(tipoEjecucion == 'N') // Ejecucion normal DYV { rota90GradosDivide(0,0,img.alto,img.ancho,&img,img.alto); } else if (tipoEjecucion == 'H') // Ejecucion con hilos DYV { rota90GradosDivideThreads(0,0,img.alto,img.ancho,&img,img.alto); } else // Rotacion clásica { rotacionClasica(&img,&img); } uswtime(&usrtime21, &systime21, &walltime21); // Calculo de los tiempos real = walltime21 - walltime11; user = usrtime21 - usrtime11; sys = systime21 - systime11; cpuwall = ((user + sys) * 100.0) / real; // Salida de resultados if(tipoEjecucion == 'N') printf("Normal DYV|%d|%.10f|%.10f|%.10f|%.10f\n",img.alto,real,user,sys,cpuwall); else if (tipoEjecucion == 'H') printf("Hilos DYV|%d|%.10f|%.10f|%.10f|%.10f\n",img.alto,real,user,sys,cpuwall); else printf("Clasica|%d|%.10f|%.10f|%.10f|%.10f\n",img.alto,real,user,sys,cpuwall); guardarImagen(&img, IMAGEN_OUT); //Terminar programa normalmente exit(0); }
int main(int a,char* args[]){ double utime0, stime0, wtime0,utime1, stime1, wtime1; //Variables para medición de tiempos int *numeros,n,i; Nodo *arbol; uswtime(&utime0, &stime0, &wtime0); numeros = (int*)malloc(10000000*sizeof(int)); arbol = NULL; //Limite de numeros n = atoi(args[1]); //Leer n numeros del archivo for(i = 0;i < n;i++){ scanf("%d",&numeros[i]); //printf("%d ",numeros[i]); } //putchar('\n'); //Implementacion del Arbol Binario for(i = 0;i < n;i++){ inserta(&arbol,numeros[i]); }//Fin For printf("====================NUMEROS=================\n"); //Recorremos el Arbol InOrden para obtener los Numero Ordenados (Imprime) inOrden(arbol); printf("!===================NUMEROS=================!\n"); uswtime(&utime1, &stime1, &wtime1); //Cálculo del tiempo de ejecución del programa printf("\n"); printf("real (Tiempo total) %.10f s\n", wtime1 - wtime0); printf("user (Tiempo de procesamiento en CPU) %.10f s\n", utime1 - utime0); printf("sys (Tiempo en acciónes de E/S) %.10f s\n", stime1 - stime0); printf("CPU/Wall %.10f %% \n",100.0 * (utime1 - utime0 + stime1 - stime0) / (wtime1 - wtime0)); printf("\n"); //Mostrar los tiempos en formato exponecial printf("\n"); printf("real (Tiempo total) %.10e s\n", wtime1 - wtime0); printf("user (Tiempo de procesamiento en CPU) %.10e s\n", utime1 - utime0); printf("sys (Tiempo en acciónes de E/S) %.10e s\n", stime1 - stime0); printf("CPU/Wall %.10f %% \n",100.0 * (utime1 - utime0 + stime1 - stime0) / (wtime1 - wtime0)); printf("\n"); //****************************************************************** return 1; }
int main(int argc,char *argv[]){ double utime0, stime0, wtime0,utime1, stime1, wtime1; //Variables para medición de tiempos int n; n = atoi(argv[1]); int nums[n], i; uswtime(&utime0, &stime0, &wtime0); for(i=0; i < n; i++){ scanf("%d", &nums[i]); } uswtime(&utime0, &stime0, &wtime0); selection_sort(nums, n); uswtime(&utime1, &stime1, &wtime1); printf("====================NUMEROS=================\n"); for(i=0;i<n;i++) printf("%d\n", nums[i]); printf("!===================NUMEROS=================!\n"); //Cálculo del tiempo de ejecución del programa printf("\n"); printf("real (Tiempo total) %.10f s\n", wtime1 - wtime0); printf("user (Tiempo de procesamiento en CPU) %.10f s\n", utime1 - utime0); printf("sys (Tiempo en acciónes de E/S) %.10f s\n", stime1 - stime0); printf("CPU/Wall %.10f %% \n",100.0 * (utime1 - utime0 + stime1 - stime0) / (wtime1 - wtime0)); printf("\n"); //Mostrar los tiempos en formato exponecial printf("\n"); printf("real (Tiempo total) %.10e s\n", wtime1 - wtime0); printf("user (Tiempo de procesamiento en CPU) %.10e s\n", utime1 - utime0); printf("sys (Tiempo en acciónes de E/S) %.10e s\n", stime1 - stime0); printf("CPU/Wall %.10f %% \n",100.0 * (utime1 - utime0 + stime1 - stime0) / (wtime1 - wtime0)); printf("\n"); //****************************************************************** return 1; }