69 #include <sys/times.h> 70 #include <sys/types.h> 77 #include <sys/times.h> 82 #include <sys/times.h> 102 double system_time,total_time,user_time;
104 struct tbuffer current_time;
106 times(¤t_time);
107 user_time = ((double)(current_time.proc_user_time))/100.0;
108 system_time = ((double)(current_time.proc_system_time))/100.0;
111 struct tms current_time;
113 times(¤t_time);
114 user_time = ((double)(current_time.tms_utime))/((
double)(CLOCKS_PER_SEC));
115 system_time = ((double)(current_time.tms_stime))/((
double)(CLOCKS_PER_SEC));
118 clock_t current_time;
120 current_time = clock();
121 user_time = ((double)(current_time)/(double)(CLOCKS_PER_SEC));
125 struct tms current_time;
127 times(¤t_time);
128 user_time = ((double)(current_time.tms_utime))/((
double)sysconf(_SC_CLK_TCK));
129 system_time = ((double)(current_time.tms_stime))/((
double)sysconf(_SC_CLK_TCK));
132 struct tms current_time;
134 times(¤t_time);
135 user_time = ((double)(current_time.tms_utime))/((
double)sysconf(_SC_CLK_TCK));
136 system_time = ((double)(current_time.tms_stime))/((
double)sysconf(_SC_CLK_TCK));
139 total_time = user_time+system_time;
145 *return_time = total_time;
149 *return_time = user_time;
153 *return_time = system_time;
158 strcpy(error_string,
"Invalid operation code");
159 *return_time = -99999.0;
void CPUTimer(double *return_time, int *flag, int *err, char error_string[])