0001-cmdline-nruns.patch 1.3 KB

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