ejercicios_threads_2_nov_2019
Diferencias
Muestra las diferencias entre dos versiones de la página.
Ambos lados, revisión anteriorRevisión previaPróxima revisión | Revisión previaÚltima revisiónAmbos lados, revisión siguiente | ||
ejercicios_threads_2_nov_2019 [2019/11/02 10:27] – froux | ejercicios_threads_2_nov_2019 [2019/11/02 10:30] – froux | ||
---|---|---|---|
Línea 9: | Línea 9: | ||
c) Realizar un nuevo programa igual al del punto a) pero en lugar de usar threads, usar funciones comunes. Medir el tiempo de ejecución de los 2 programas y comparar. Puede utilizarse la siguiente funcion: | c) Realizar un nuevo programa igual al del punto a) pero en lugar de usar threads, usar funciones comunes. Medir el tiempo de ejecución de los 2 programas y comparar. Puede utilizarse la siguiente funcion: | ||
- | double what_time_is_it() | + | double what_time_is_it() |
- | { | + | |
- | struct timespec now; | + | struct timespec now; |
- | clock_gettime(CLOCK_REALTIME, | + | clock_gettime(CLOCK_REALTIME, |
- | return now.tv_sec + now.tv_nsec*1e-9; | + | return now.tv_sec + now.tv_nsec*1e-9; |
- | } | + | |
- | int main () { | + | int main () { |
- | double inicio, fin, dif; | + | double inicio, fin, dif; |
+ | inicio = what_time_is_it(); | ||
- | | + | // programa |
- | // programa | + | fin = what_time_is_it(); |
+ | dif = fin - inicio; | ||
+ | printf(" | ||
- | fin = what_time_is_it(); | + | return 0; |
- | dif = fin - inicio; | + | |
- | + | ||
- | | + | |
- | + | ||
- | return 0; | + | |
- | } | + | |
ejercicios_threads_2_nov_2019.txt · Última modificación: 2019/11/02 10:30 por froux