ADS29009-2019-1
Ir para navegação
Ir para pesquisar
- include <sys/time.h>
- include <sys/types.h>
- include <unistd.h>
- include <stdio.h>
int main()
{
long int i;
double tempo_bloco;
for (i=0;i<23;i++) {
if (fork()==0) {
struct timeval start, end;
gettimeofday(&start, NULL);
for (i=0; i<10000000000L; i++)
{
}
gettimeofday(&end, NULL);
tempo_bloco = (end.tv_sec - start.tv_sec) * 1e6;
tempo_bloco = (tempo_bloco + (end.tv_usec -
start.tv_usec)) * 1e-6;
printf("Tempo = %lf\n", tempo_bloco);
return 0;
}
}
}
</syntaxhighlight>