Используйте вызов времени - в соответствии со страницей руководства:
NAME
времена - получить время процесса
СИНТАКСИС
#include
clock_t times(struct tms *buf);
ОПИСАНИЕ
times () хранит текущее время процесса в структуре, на которую указывает buf. Структура
TMS определен в:
struct tms {
clock_t tms_utime; /* user time */
clock_t tms_stime; /* system time */
clock_t tms_cutime; /* user time of children */
clock_t tms_cstime; /* system time of children */
};
The tms_utime field contains the CPU time spent executing instructions of the calling
process. The tms_stime field contains the CPU time spent in the system while executing
tasks on behalf of the calling process. The tms_cutime field contains the sum of the
tms_utime and tms_cutime values for all waited-for terminated children. The tms_cstime
field contains the sum of the tms_stime and tms_cstime values for all waited-for terminated
children.