home *** CD-ROM | disk | FTP | other *** search
/ Troubleshooting Netware Systems / CSTRIAL0196.BIN / attach / msj / v10n05 / dynvxd.exe / VCYCLASM.EXE / VXDTEST.C < prev   
C/C++ Source or Header  |  1995-05-01  |  3KB  |  74 lines

  1. /*****************************************************************************/
  2. /*                                                                           */
  3. /*    VXDTEST.C -- Test program for VCYCLE.VXD                               */
  4. /*                                                                           */
  5. /*    Written by Walter Oney                                                 */
  6. /*                                                                           */
  7. /*****************************************************************************/
  8.  
  9. #define WIN32_LEAN_AND_MEAN
  10. #include <windows.h>
  11. #include <stdio.h>
  12. #include <string.h>
  13.  
  14. DWORD counter[2];                   // RDTSC counter
  15.  
  16. void dotest(void)
  17.     {                               // dotest
  18.     _asm
  19.         {                           // get starting timestamp
  20.         _emit 0Fh                   ; Pentium RDTSC
  21.         _emit 31h
  22.         mov counter, eax            ; save counter
  23.         mov counter+4, edx
  24.         }                           // get starting timestamp
  25.  
  26.     Sleep(500);                     // sleep for 1/2 second
  27.  
  28.     _asm
  29.         {                           // compute delta between now and start
  30.         _emit 0Fh                   ; RDTSC
  31.         _emit 31h
  32.         sub eax, counter            ; compute delta since start
  33.         sbb edx, counter+4
  34.         mov counter, eax            ; save as return value
  35.         mov counter+4, edx
  36.         }                           // compute delta between now and start
  37.     }                               // dotest
  38.  
  39. int main(int argc, char *argv[])
  40.     {                               // main
  41.     HANDLE hDevice;
  42.  
  43.     hDevice = CreateFile("\\\\.\\VCYCLE.VXD", 0, 0, NULL, 0,
  44.         FILE_FLAG_DELETE_ON_CLOSE, NULL);
  45.     if (hDevice != INVALID_HANDLE_VALUE)
  46.         {                           // talk to device
  47.         DWORD version;
  48.         DWORD nret;
  49.         LPDWORD pcounter = counter;
  50.  
  51.         DeviceIoControl(hDevice, 1, NULL, 0, &version, sizeof(version),
  52.             &nret, NULL);
  53.         printf("VCYCLE.VXD is version %d.%02d\n", HIBYTE(version),
  54.             LOBYTE(version));
  55.  
  56.         dotest();
  57.         printf("Elapsed time measured without virtualization is %ld\n",
  58.             counter[0]);
  59.  
  60.         DeviceIoControl(hDevice, 2, &pcounter, sizeof(pcounter), NULL, 0,
  61.             NULL, NULL);
  62.         dotest();
  63.         printf("Elapsed time measured with virtualization is %ld\n",
  64.             counter[0]);
  65.         pcounter = NULL;
  66.         DeviceIoControl(hDevice, 2, &pcounter, sizeof(pcounter), NULL,
  67.             0, NULL, NULL);
  68.  
  69.         CloseHandle(hDevice);
  70.         }                           // talk to device
  71.     return 0;
  72.     }                               // main
  73.  
  74.