From 19238dc05c5b501a685537b1fcb0b54f9d8bdf5a Mon Sep 17 00:00:00 2001 From: David Leonard Date: Thu, 3 Sep 1998 11:04:48 +0000 Subject: libpthread tests modified for uthreads --- lib/libc_r/TEST/p_bench_getpid.c | 75 ++++++++++++++++++++++++++++++++++++++++ 1 file changed, 75 insertions(+) create mode 100644 lib/libc_r/TEST/p_bench_getpid.c (limited to 'lib/libc_r/TEST/p_bench_getpid.c') diff --git a/lib/libc_r/TEST/p_bench_getpid.c b/lib/libc_r/TEST/p_bench_getpid.c new file mode 100644 index 00000000000..45fbc2d4500 --- /dev/null +++ b/lib/libc_r/TEST/p_bench_getpid.c @@ -0,0 +1,75 @@ +/* ==== p_bench_getpid.c ================================================= + * Copyright (c) 1993 by Chris Provenzano, proven@athena.mit.edu + * + * Description : Benchmark getpid() times + * + * 1.00 93/11/08 proven + * -Started coding this file. + */ + +#include +#include +#include +#include +#include +#include "test.h" + +/* ========================================================================== + * usage(); + */ +void usage(void) +{ + printf("p_bench_getpid [-d?] [-c count]\n"); + errno = 0; +} + +int +main(int argc, char **argv) +{ + struct timeval starttime, endtime; + pid_t process_id; + int count = 1000000; + int debug = 0; + int i; + + char word[256]; + + /* Getopt variables. */ + extern int optind, opterr; + extern char *optarg; + + while ((word[0] = getopt(argc, argv, "c:d?")) != (char)EOF) { + switch (word[0]) { + case 'd': + debug++; + break; + case 'c': + count = atoi(optarg); + break; + case '?': + usage(); + return(OK); + default: + usage(); + return(NOTOK); + } + } + + if (gettimeofday(&starttime, NULL)) { + perror ("gettimeofday"); + return 1; + } + for (i = 0; i < count; i++) { + process_id = getpid(); + } + if (gettimeofday(&endtime, NULL)) { + perror ("gettimeofday"); + return 1; + } + + printf("%d getpid calls took %ld usecs.\n", count, + (endtime.tv_sec - starttime.tv_sec) * 1000000 + + (endtime.tv_usec - starttime.tv_usec)); + + return 0; +} -- cgit v1.2.3