source: trunk/src/win32k/test/PrfTstProcess.c@ 6666

Last change on this file since 6666 was 6495, checked in by bird, 24 years ago

Made useable NT version. Result from Citrix Server.

File size: 8.2 KB
Line 
1/* $Id: PrfTstProcess.c,v 1.3 2001-08-08 21:54:45 bird Exp $
2 *
3 * Test program which checks how long it takes to execute another
4 * instance of itself and run
5 *
6 * Copyright (c) 2001 knut st. osmundsen (knut.stange.osmundsen@mynd.no)
7 *
8 * Project Odin Software License can be found in LICENSE.TXT
9 *
10 */
11
12/** @design Process Startup and Termination cost.
13 *
14 * The purpose is to compare the cost of creating a child process on different
15 * platforms; revealing which is the best ones...
16 *
17 * Later analysis on why will be done I hope...
18 *
19 *
20 * @subsection Test Results
21 *
22 * Linux version 2.4.5 (SMP) Pentium III 700Mhz- GCC:
23 * 0.001845 - 0.001845 sec (pid=193c)
24 * 0.001832 - 0.001832 sec (pid=193e)
25 * 0.001792 - 0.001792 sec (pid=1940)
26 * 0.001899 - 0.001899 sec (pid=1942)
27 *
28 * OS/2 WS4eB 4.5 FP 2 (SMP) Pentium III 600Mhz - Watcom -Otx:
29 * 5150.000000 - 0.004316 sec (pid=0)
30 * 5175.000000 - 0.004337 sec (pid=0)
31 * 5143.000000 - 0.004310 sec (pid=0)
32 * 5181.000000 - 0.004342 sec (pid=0)
33 *
34 * OS/2 WS4eB 4.5 FP 2 (SMP) Pentium III 600Mhz - Watcom (no optimization):
35 * 5510.000000 - 0.004618 sec (pid=0)
36 * 5500.000000 - 0.004610 sec (pid=0)
37 * 5489.000000 - 0.004600 sec (pid=0)
38 * 5551.000000 - 0.004652 sec (pid=0)
39 *
40 * OS/2 WS4eB 4.5 FP 2 (SMP) Pentium III 600Mhz - VAC308:
41 * 6490.000000 - 0.005439 sec (pid=0)
42 * 6465.000000 - 0.005418 sec (pid=0)
43 * 6501.000000 - 0.005449 sec (pid=0)
44 * 6496.000000 - 0.005444 sec (pid=0)
45 *
46 * Citrix Server (NT4) (SMP) Pentium III 800Mhz - Watcom -Otx:
47 * 4380885.000000 - 0.005493 sec (pid=0) (Hz: 797510000)
48 * 4411477.000000 - 0.005532 sec (pid=0)
49 * 4339893.000000 - 0.005442 sec (pid=0)
50 * 4349910.000000 - 0.005454 sec (pid=0)
51 *
52 * Citrix Server (NT4) (SMP) Pentium III 800Mhz - Watcom (no optimization):
53 * 4351488.000000 - 0.005456 sec (pid=0) (Hz: 797510000)
54 * 4411035.000000 - 0.005531 sec (pid=0)
55 * 4362396.000000 - 0.005470 sec (pid=0)
56 * 4374720.000000 - 0.005485 sec (pid=0)
57 *
58 * OS/2 WS4eB 4.5 FP 2 (SMP) Pentium III 600Mhz - VAC365:
59 * 6743.000000 - 0.005651 sec (pid=0)
60 * 6694.000000 - 0.005610 sec (pid=0)
61 * 6705.000000 - 0.005619 sec (pid=0)
62 * 7025.000000 - 0.005888 sec (pid=0)
63 *
64 * OS/2 WS4eB 4.5 FP 2 (SMP) Pentium III 600Mhz - EMX -D__OS2__:
65 * 15339.000000 - 0.012856 sec (pid=0)
66 * 15507.000000 - 0.012997 sec (pid=0)
67 * 15224.000000 - 0.012759 sec (pid=0)
68 * 15714.000000 - 0.013170 sec (pid=0)
69 *
70 * OS/2 WS4eB 4.5 FP 2 (SMP) Pentium III 600Mhz - EMX -D__OS2__ -D__NOTPC__:
71 * 31992.000000 - 0.026813 sec (pid=1c7f)
72 * 32300.000000 - 0.027071 sec (pid=1c82)
73 * 31699.000000 - 0.026567 sec (pid=1c85)
74 * 33570.000000 - 0.028135 sec (pid=1c88)
75 *
76 * @subsection Compilation OS/2
77 * Just as normal odin apps:<br>
78 * nmake -f prftstprocess.mak
79 *
80 * @subsection Complation NT
81 * This works from OS/2 and NT:
82 * wcl386 -d__WINNT__=1 -bt=nt /lnt -I%WATCOM\h\nt PrfTstProcess.c kernel32.lib
83 *
84 * Optimized:
85 * wcl386 -Otx -d__WINNT__=1 -bt=nt /lnt -I%WATCOM\h\nt PrfTstProcess.c kernel32.lib
86 *
87 */
88
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
101long double gettime(void)
102{
103 QWORD qw;
104 DosTmrQueryTime(&qw);
105 return (long double)qw.ulHi * (4294967296.00) + qw.ulLo;
106}
107
108unsigned getHz(void)
109{
110 ULONG ul = -1;
111 DosTmrQueryFreq(&ul);
112 return ul;
113}
114
115void printSystemInfo(void)
116{
117}
118
119#elif defined(__WINNT__)
120#include <windows.h>
121/*
122 * Windows
123 */
124unsigned long __stdcall GetTickCount(void);
125
126long 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
135unsigned getHz(void)
136{
137 //return 1000;
138 LARGE_INTEGER ullFrequency;
139 ullFrequency.QuadPart = 0;
140 QueryPerformanceFrequency(&ullFrequency);
141 return (unsigned)ullFrequency.QuadPart;
142}
143
144void 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
242long 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
252unsigned getHz(void)
253{
254 return 1;//000000;
255}
256
257void printSystemInfo(void)
258{
259}
260
261#endif
262
263
264int main(int argc, char **argv)
265{
266 long double rdStart;
267 long double rdEnd;
268 int pid;
269 #ifdef __NOTPC__
270 int status;
271 #endif
272
273 /*
274 * Child process test.
275 */
276 if (argc != 1)
277 return 0;
278
279 /*
280 * Main process.
281 */
282 rdStart = gettime();
283 #ifndef __NOTPC__
284 pid = spawnl(P_WAIT, argv[0], argv[0], "child", NULL); /* pid == 0 on success */
285 #else
286 pid = fork();
287 if (pid == 0)
288 {/* child code */
289 execl(argv[0], argv[0], "child", NULL);
290 fprintf(stderr, "we should NEVER be here!!\n");
291 return 0;
292 }
293 if (pid > 0)
294 pid = wait(&status);
295 #endif
296 rdEnd = gettime();
297 printf("%Lf - %Lf sec (pid=%x)\n", rdEnd - rdStart, (rdEnd - rdStart) / getHz(), pid);
298 printf("(start: %Lf end: %Lf Hz: %d\n", rdStart, rdEnd, getHz());
299 printSystemInfo();
300 return 0;
301}
Note: See TracBrowser for help on using the repository browser.