times.c

sima/test/times.c · 377 B

From the archive 970706-sima.tgz

Download the archive   « Back to the archive contents

#include <sys/times.h>
#include <unistd.h>

#define TIMES_FREQ sysconf(_SC_CLK_TCK)

volatile int uid = 0;


int main() {
    struct tms tms;

    int i = 1000000;
    do {
	if (uid)
	    times(&tms);
    } while (--i);
    times(&tms);
    printf("user time:%f system time:%f\n",
	(double)tms.tms_utime / TIMES_FREQ,
	(double)tms.tms_stime / TIMES_FREQ
    );
    return 0;
}

Site Stats

Snippets: 1791
Codebases: 571