For the following code getrusage returning zeros in ru_utime.tv_usec
and ru_utime.tv_sec
.
Code:
#include "stdlib.h"
#include "stdio.h"
#include "sys/time.h"
#include "sys/resource.h"
int getr_return, who = RUSAGE_SELF;
struct rusage usage;
main()
{
getr_return = getrusage(who, &usage);
printf(" getr_return = %d\n", getr_return);
printf(" time taken in seconds = %.61f\n", usage.ru_utime.tv_sec);
printf(" time taken in seconds = %.61f\n", usage.ru_utime.tv_usec);
Some_Mips_consuming_code().
getr_return = getrusage(who, &usage);
printf(" getr_return = %d\n", getr_return);
printf(" time taken in seconds = %.61f\n", usage.ru_utime.tv_sec);
printf(" time taken in seconds = %.61f\n", usage.ru_utime.tv_usec);
exit;
}
output:
getr_return = 0
time taken in seconds = 0.0000000000000000000000000000000000000000000000000000000000000
time taken in seconds = 0.0000000000000000000000000000000000000000000000000000000000000
getr_return = 0
time taken in seconds = 0.0000000000000000000000000000000000000000000000000000000000000
time taken in seconds = 0.0000000000000000000000000000000000000000000000000000000000000
Compiled code on Linux version 2.6.18-308
Ran executable on ARM board and it's Linux version 3.8.1-2.0