Date: Wed, 16 Aug 2006 06:00:06 GMT From: Chris Jones <cdjones@FreeBSD.org> To: Perforce Change Reviews <perforce@FreeBSD.org> Subject: PERFORCE change 104183 for review Message-ID: <200608160600.k7G60677022115@repoman.freebsd.org>
next in thread | raw e-mail | index | archive | help
http://perforce.freebsd.org/chv.cgi?CH=104183 Change 104183 by cdjones@cdjones-impulse on 2006/08/16 06:00:03 Add some useful options for chewing through CPU. Affected files ... .. //depot/projects/soc2006/cdjones_jail/test/useCpu.c#2 edit Differences ... ==== //depot/projects/soc2006/cdjones_jail/test/useCpu.c#2 (text+ko) ==== @@ -6,11 +6,48 @@ #include <string.h> #include <unistd.h> +static void usage(void); +extern char **environ; + int main(int argc, char **argv) { + int ch; + unsigned int repeats = 0; + unsigned int verbose = 0; + unsigned int interval = 1000; int a; - while (1) - a = 1 + 2; + while ((ch = getopt(argc, argv, "vn:i:")) != -1) { + switch (ch) { + case 'n': + repeats = atoi(optarg); + break; + case 'i': + interval = atoi(optarg); + break; + case 'v': + verbose = 1; + break; + default: + usage(); + } + } + argc -= optind; + argv += optind; + + while (repeats) { + a = (0xdeadbeef * 2) + -1; + if (verbose && 0 == (repeats % interval)) + printf("repeat: %d\n", repeats); + repeats--; + } + exit(0); +} + +static void +usage(void) +{ + (void) fprintf(stderr, "%s\n", + "usage: useCpu [-v] [-i interval] [-n count]"); }
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?200608160600.k7G60677022115>