I haven't done much C-programming (or programming at all actually, except for java the last year), but here's my question:
Is there anything wrong with this tiny program?
One time it said a couple of million seconds on children, and I thought that was kind of weird. Now it says under a second on everything. It is supposed to give me the user and system time used by the current process, right? Anyway, I would really appreciate the help
Is there anything wrong with this tiny program?
Code:
#include <stdio.h>
#include <unistd.h>
#include <sys/resource.h>
#include <sys/time.h>
int main(void)
{
[INDENT]struct rusage self,children;
getrusage(RUSAGE_SELF,&self);
getrusage(RUSAGE_CHILDREN,&children);
double self_utime=(double)self.ru_utime.tv_sec+1.e-6*(double)self.ru_utime.tv_usec;
double self_stime=(double)self.ru_stime.tv_sec+1.e-6*(double)self.ru_stime.tv_usec;
double children_utime=(double)children.ru_utime.tv_sec+1.e-6*(double)children.ru_utime.tv_usec;
double children_stime(double)children.ru_stime.tv_sec+1.e-6*(double)children.ru_stime.tv_usec;
printf("SELF: user %f, system %f\n", self_utime, self_stime);
printf("CHILDREN: user %f, system %f\n", children_utime, children_stime);
return 0;[/INDENT]
}
One time it said a couple of million seconds on children, and I thought that was kind of weird. Now it says under a second on everything. It is supposed to give me the user and system time used by the current process, right? Anyway, I would really appreciate the help