1let people specify the number of runs on the command line 2 3Patch by Vivi Li <vivi.li@analog.com> 4 5--- a/dhry_1.c 6+++ b/dhry_1.c 7@@ -66,7 +70,7 @@ 8 /* end of variables for time measurement */ 9 10 11-main () 12+main(int argc, char *argv[]) 13 /*****/ 14 15 /* main program, corresponds to procedures */ 16@@ -101,6 +105,13 @@ 17 /* Warning: With 16-Bit processors and Number_Of_Runs > 32000, */ 18 /* overflow may occur for this array element. */ 19 20+ Number_Of_Runs = 0; 21+ if ( argc == 2 ) { 22+ if (atoi(argv[1]) > 0) { 23+ Number_Of_Runs = atoi(argv[1]); 24+ } 25+ } 26+ 27 printf ("\n"); 28 printf ("Dhrystone Benchmark, Version 2.1 (Language: C)\n"); 29 printf ("\n"); 30@@ -114,13 +125,17 @@ 31 printf ("Program compiled without 'register' attribute\n"); 32 printf ("\n"); 33 } 34- printf ("Please give the number of runs through the benchmark: "); 35- { 36- int n; 37- scanf ("%d", &n); 38- Number_Of_Runs = n; 39+ 40+ if (!Number_Of_Runs) { 41+ printf ("Please give the number of runs through the benchmark: "); 42+ fflush (stdout); 43+ { 44+ int n; 45+ scanf ("%d", &n); 46+ Number_Of_Runs = n; 47+ } 48+ printf ("\n"); 49 } 50- printf ("\n"); 51 52 printf ("Execution starts, %d runs through Dhrystone\n", Number_Of_Runs); 53 54