Advertisement
Guest User

Untitled

a guest
Jun 28th, 2017
60
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.48 KB | None | 0 0
  1.  
  2.  
  3. uint32_t stampstart() {//Registra el tiempo de inicio.. su retorno se usa en la funcion de tiempo Final.
  4. struct timeval tv;
  5. struct timezone tz;
  6. struct tm *tm;
  7. uint32_t start;
  8.  
  9. gettimeofday(&tv, &tz);
  10. tm = localtime(&tv.tv_sec);
  11. /*printf("Inicio\t %d:%02d:%02d:%d (~%d ms)\n", tm->tm_hour,
  12. tm->tm_min, tm->tm_sec, tv.tv_usec,
  13. tm->tm_hour * 3600 * 1000 + tm->tm_min * 60 * 1000 +
  14. tm->tm_sec * 1000 + tv.tv_usec / 1000);*/
  15.  
  16. start = tm->tm_hour * 3600 * 1000 + tm->tm_min * 60 * 1000 +
  17. tm->tm_sec * 1000 + tv.tv_usec / 1000;
  18.  
  19. return (start);
  20.  
  21. }
  22.  
  23. uint32_t stampstop(uint32_t start){ //Recibe el tiempo de partida y lo resta con el tiempo final para sacar el Total en milisegundos.
  24. struct timeval tv;
  25. struct timezone tz;
  26. struct tm *tm;
  27. uint32_t stop;
  28.  
  29. gettimeofday(&tv, &tz);
  30. tm = localtime(&tv.tv_sec);
  31.  
  32. stop = tm->tm_hour * 3600 * 1000 + tm->tm_min * 60 * 1000 +
  33. tm->tm_sec * 1000 + tv.tv_usec / 1000;
  34.  
  35. /*printf("\nFin\t %d:%02d:%02d:%d (~%d ms)\n", tm->tm_hour,
  36. tm->tm_min, tm->tm_sec, tv.tv_usec,
  37. tm->tm_hour * 3600 * 1000 + tm->tm_min * 60 * 1000 +
  38. tm->tm_sec * 1000 + tv.tv_usec / 1000);
  39. */
  40. printf("\nTiempo Total Transcurrido\t %d milisegundos.\n", stop - start);
  41. return (stop);
  42.  
  43. }
  44.  
  45. // para usarlas
  46.  
  47. void main(){
  48. uint32_t start, stop;
  49. start = stampstart(); // Inicio del proceso
  50. //algunawea();
  51. stop = stampstop(start);// Fin del proceso
  52. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement