Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- uint32_t stampstart() {//Registra el tiempo de inicio.. su retorno se usa en la funcion de tiempo Final.
- struct timeval tv;
- struct timezone tz;
- struct tm *tm;
- uint32_t start;
- gettimeofday(&tv, &tz);
- tm = localtime(&tv.tv_sec);
- /*printf("Inicio\t %d:%02d:%02d:%d (~%d ms)\n", tm->tm_hour,
- tm->tm_min, tm->tm_sec, tv.tv_usec,
- tm->tm_hour * 3600 * 1000 + tm->tm_min * 60 * 1000 +
- tm->tm_sec * 1000 + tv.tv_usec / 1000);*/
- start = tm->tm_hour * 3600 * 1000 + tm->tm_min * 60 * 1000 +
- tm->tm_sec * 1000 + tv.tv_usec / 1000;
- return (start);
- }
- uint32_t stampstop(uint32_t start){ //Recibe el tiempo de partida y lo resta con el tiempo final para sacar el Total en milisegundos.
- struct timeval tv;
- struct timezone tz;
- struct tm *tm;
- uint32_t stop;
- gettimeofday(&tv, &tz);
- tm = localtime(&tv.tv_sec);
- stop = tm->tm_hour * 3600 * 1000 + tm->tm_min * 60 * 1000 +
- tm->tm_sec * 1000 + tv.tv_usec / 1000;
- /*printf("\nFin\t %d:%02d:%02d:%d (~%d ms)\n", tm->tm_hour,
- tm->tm_min, tm->tm_sec, tv.tv_usec,
- tm->tm_hour * 3600 * 1000 + tm->tm_min * 60 * 1000 +
- tm->tm_sec * 1000 + tv.tv_usec / 1000);
- */
- printf("\nTiempo Total Transcurrido\t %d milisegundos.\n", stop - start);
- return (stop);
- }
- // para usarlas
- void main(){
- uint32_t start, stop;
- start = stampstart(); // Inicio del proceso
- //algunawea();
- stop = stampstop(start);// Fin del proceso
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement