I found the code given below on the net sampling the use og getrusage. But when I tried to execute it in VC++6.0 it couldn't find sys/time.h and sys/resource.h. I tried searching for these headers on net but they themselves gave errors requiring files not present in my sys dir. If u could tell me or give me these header files(error free), that could be really appreciative.
I have these files in my sys dir right now:
Locking.h, stat.h, timeb.h,types.h,Utime.h
Though i have time.h in Include dir and the code then compiles yo give 1 error of that resource.h only.. though m not sure its the same time.h as req.. thers one resource odl file in INCLUDE dir also..
#include<stdio.h>
#include<stdlib.h>
#include<sys/time.h>
#include<sys/resource.h>
double getcputime();
int main(void)
{
int i, n, a;
double t;
n = 13;
printf("The 5-times Table\n");
for(i=1;i<n;i++)
{
a = (i * 7);
printf("%d\t%d\n", i, a);
}
printf("\n");
t = getcputime();
printf("The total time taken by the system is: %d (in decimal format)\n", t);
return 0;
}
double getcputime(void)
{
double t;
struct timeval tim;
struct rusage ru;
getrusage(RUSAGE_SELF, &ru);
tim=ru.ru_stime;
t=(double)tim.tv_sec * 1000000.0 + (double)tim.tv_usec;
return t;
}
Those look like unix/linux directories So you could well have problems here.
I checked on the web and this is what I found: http://linux.die.net/man/2/getrusage
Maybe the unix/Linux guys on here can elaborate more