Changeset 10056 for trunk/src


Ignore:
Timestamp:
May 1, 2003, 1:20:51 PM (22 years ago)
Author:
bird
Message:

Initial coding / fixup.

Location:
trunk/src/win32k/test
Files:
4 added
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/win32k/test/PrfTstProcess.c

    r6495 r10056  
    1 /* $Id: PrfTstProcess.c,v 1.3 2001-08-08 21:54:45 bird Exp $
     1/* $Id: PrfTstProcess.c,v 1.4 2003-05-01 11:20:50 bird Exp $
    22 *
    33 * Test program which checks how long it takes to execute another
     
    8787 */
    8888
    89 #include <stdio.h>
    90 #if !defined(__WINNT__)
    91 #include <sys/time.h>
    92 #endif
    93 #ifndef __NOTPC__
    94 #include <process.h>
    95 #endif
    96 
    97 #ifdef __OS2__
    98 #define INCL_DOSPROFILE
    99 #include <os2.h>
    100 
    101 long double gettime(void)
    102 {
    103     QWORD   qw;
    104     DosTmrQueryTime(&qw);
    105     return (long double)qw.ulHi * (4294967296.00) + qw.ulLo;
    106 }
    107 
    108 unsigned getHz(void)
    109 {
    110     ULONG ul = -1;
    111     DosTmrQueryFreq(&ul);
    112     return ul;
    113 }
    114 
    115 void printSystemInfo(void)
    116 {
    117 }
    118 
    119 #elif defined(__WINNT__)
    120 #include <windows.h>
    121 /*
    122  * Windows
    123  */
    124 unsigned long __stdcall GetTickCount(void);
    125 
    126 long double gettime(void)
    127 {
    128     //return (long double)GetTickCount();
    129     LARGE_INTEGER ullCounter;
    130     ullCounter.QuadPart = 0;
    131     QueryPerformanceCounter(&ullCounter);
    132     return (long double)ullCounter.QuadPart;
    133 }
    134 
    135 unsigned getHz(void)
    136 {
    137     //return 1000;
    138     LARGE_INTEGER ullFrequency;
    139     ullFrequency.QuadPart = 0;
    140     QueryPerformanceFrequency(&ullFrequency);
    141     return (unsigned)ullFrequency.QuadPart;
    142 }
    143 
    144 void printSystemInfo(void)
    145 {
    146     LONG        lrc;
    147     SYSTEM_INFO si;
    148     HKEY        hProcessor0;
    149     char        szMhz[16];
    150     szMhz[0] = '\0';
    151 
    152     lrc = RegOpenKey(HKEY_LOCAL_MACHINE,
    153                      "HARDWARE\\DESCRIPTION\\System\\CentralProcessor\\0",
    154                      &hProcessor0);
    155     if (!lrc)
    156     {
    157         LONG    cchMhz = sizeof(szMhz);
    158         DWORD   iKey;
    159         CHAR    szValueName[256];
    160         DWORD   cchValueName = sizeof(szValueName);
    161         DWORD   dwType;
    162         BYTE    abData[256];
    163         DWORD   cbData;
    164 
    165         iKey = 0;
    166         szMhz[0] = '\0';
    167         while ((lrc = RegEnumValue(hProcessor0,
    168                                    iKey,
    169                                    szValueName,
    170                                    &cchValueName,
    171                                    NULL,
    172                                    &dwType,
    173                                    &abData,
    174                                    &cbData)) == 0
    175                || lrc == ERROR_MORE_DATA)
    176         {
    177             switch (dwType)
    178             {
    179                 case REG_SZ:
    180                 case REG_EXPAND_SZ:
    181                     /*
    182                     printf("%-24s =  type: %1x  namesize: %2d  data size: %3d bytes\n          %s\n",
    183                            szValueName, dwType, cchValueName, cbData, &abData[0]);
    184                     */
    185                     break;
    186 
    187                 default:
    188                 {
    189                     /*
    190                     int i,j;
    191                     printf("%-24s =  type: %1x  namesize: %2d  data size: %3d bytes\n",
    192                            szValueName, dwType, cchValueName, cbData);
    193                     for (i = 0; i < cbData; i += 16)
    194                     {
    195                         printf("    %04x ", i);
    196                         for (j = 0; j < 16; j++)
    197                         {
    198                             if (j + i < cbData)
    199                                 printf(j == 8 ? "-  %02x " : "%02x ",
    200                                        (BYTE)abData[i+j]);
    201                             else
    202                                 printf(j == 8 ? "    " : "   ");
    203                         }
    204                         putc(' ', stdout);
    205                         for (j = 0; j < 16; j++)
    206                         {
    207                             if (j+i < cbData)
    208                                 putc(isprint(abData[j]) ? abData[j] : '.', stdout);
    209                             else
    210                                 putc(' ', stdout);
    211                         }
    212                         putc('\n', stdout);
    213                     }
    214                     */
    215                     if (   !szMhz[0]
    216                         && stricmp(szValueName, "~MHz") == 0
    217                         && dwType == REG_DWORD
    218                         && cbData == sizeof(DWORD))
    219                         sprintf(szMhz, "%d", *(PDWORD)&abData[0]);
    220                 }
    221             }
    222 
    223             /* next */
    224             iKey++;
    225             dwType = 0;
    226             cchValueName = sizeof(szValueName);
    227             szValueName[0] = '\0';
    228         }
    229         RegCloseKey(hProcessor0);
    230     }
    231 
    232     GetSystemInfo(&si);
    233     printf("  %d %d CPUs  %s Mhz\n",
    234            si.dwNumberOfProcessors,
    235            si.dwProcessorType,
    236            szMhz
    237            );
    238 }
    239 
    240 #else
    241 
    242 long double gettime(void)
    243 {
    244     struct  timeval tp;
    245     long    sec = 0L;
    246 
    247     if (gettimeofday(&tp, NULL))
    248         return -1;
    249     return tp.tv_usec / 1000000.00 + tp.tv_sec;
    250 }
    251 
    252 unsigned getHz(void)
    253 {
    254     return 1;//000000;
    255 }
    256 
    257 void printSystemInfo(void)
    258 {
    259 }
    260 
    261 #endif
     89#include "PrfTiming.h"
    26290
    26391
Note: See TracChangeset for help on using the changeset viewer.