PERFORCE change 104183 for review
Chris Jones
cdjones at FreeBSD.org
Wed Aug 16 06:00:07 UTC 2006
http://perforce.freebsd.org/chv.cgi?CH=104183
Change 104183 by cdjones at 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]");
}
More information about the p4-projects
mailing list