#include #include #include #include int main() { struct tms process_times; clock_t start_time, finish_time; printf("Running ps with system\n"); start_time = times(0); /* get time clicks at start */ /* NOTE: The above code does not work in Sun Solaris where the */ /* parameter must point to a tms structure and not be NULL */ system("ps -ax"); finish_time = times(&process_times); printf("Done.\n"); printf("Elapsed time = %f\nUser time = %f\nSystem time = %f\n", (double)(finish_time - start_time)/CLOCKS_PER_SEC, (double)process_times.tms_cutime/CLOCKS_PER_SEC, (double)process_times.tms_cstime/CLOCKS_PER_SEC); exit(0); }