Source code of Windows XP (NT5)
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

58 lines
1.3 KiB

  1. /* execute a routine and determine the time spent...
  2. *
  3. * 26-Jan-1987 bw Clean up, add 286DOS support
  4. * 30-Oct-1987 bw Changed 'DOS5' to 'OS2'
  5. * 18-Oct-1990 w-barry Removed 'dead' code.
  6. * 28-Nov-1990 w-barry Replaced DosQuerySysInfo() with the C runtime
  7. * function 'clock' - timing is not as accurate; but,
  8. * until there is a win32 replacement, it will have to
  9. * do...
  10. */
  11. #define INCL_DOSMISC
  12. #include <process.h>
  13. #include <stdlib.h>
  14. #include <time.h>
  15. #include <stdio.h>
  16. #include <windows.h>
  17. #include <tools.h>
  18. __cdecl
  19. main (
  20. int c,
  21. char *v[]
  22. )
  23. {
  24. int i;
  25. long t, t1;
  26. char *newv[128];
  27. ConvertAppToOem( c, v );
  28. for (i = 1; i < c; i++)
  29. printf ("%s ", v[i]);
  30. printf ("\n");
  31. // newv[0] = getenv ("COMSPEC");
  32. newv[0] = getenvOem ("COMSPEC");
  33. newv[1] = "/C";
  34. for (i = 1; i < c; i++)
  35. newv[i+1] = v[i];
  36. newv[i+1] = NULL;
  37. t = clock();
  38. if ( (i = (int) _spawnvp (P_WAIT, newv[0], newv)) == -1) {
  39. printf("'%s' failed to run - %s\n", newv[0], error());
  40. exit(1);
  41. }
  42. t1 = clock();
  43. printf ("Results of execution:\n\n");
  44. printf (" Exit code %x\n", i);
  45. t1 -= t;
  46. printf (" Time of execution %ld.%03ld\n", t1 / CLK_TCK, t1 % CLK_TCK );
  47. return( 0 );
  48. }