ReactOS 0.4.15-dev-8145-ga541a46
rosperf.c File Reference
#include <limits.h>
#include <stdio.h>
#include <stdlib.h>
#include <windows.h>
#include <reactos/buildno.h>
#include "rosperf.h"
Include dependency graph for rosperf.c:

Go to the source code of this file.

Macros

#define MAINWND_WIDTH   400
 
#define MAINWND_HEIGHT   400
 
#define GOAL   2500 /* Try to get up to 2.5 seconds */
 
#define ENOUGH   2000 /* But settle for 2.0 seconds */
 
#define TICK   10 /* Assume clock not faster than .01 seconds */
 

Functions

unsigned NullInit (void **Context, PPERF_INFO PerfInfo, unsigned Reps)
 
void NullCleanup (void *Context, PPERF_INFO PerfInfo)
 
static void ProcessMessages (void)
 
static void ClearWindow (PPERF_INFO PerfInfo)
 
static unsigned CalibrateTest (PTEST Test, PPERF_INFO PerfInfo)
 
static void DisplayStatus (HWND Label, LPCWSTR Message, LPCWSTR Test, int Try)
 
static double RoundTo3Digits (double d)
 
static void ReportTimes (DWORD Time, int Reps, LPCWSTR Label, BOOL Average)
 
static void ProcessTest (PTEST Test, PPERF_INFO PerfInfo)
 
static void PrintOSVersion (void)
 
static void PrintAppVersion (void)
 
static void PrintDisplayInfo (void)
 
static void PrintStartupInfo (void)
 
static LRESULT CALLBACK MainWndProc (HWND Wnd, UINT Msg, WPARAM wParam, LPARAM lParam)
 
static LRESULT CALLBACK LabelWndProc (HWND Wnd, UINT Msg, WPARAM wParam, LPARAM lParam)
 
static HWND CreatePerfWindows (HINSTANCE hInstance, PPERF_INFO PerfInfo)
 
static BOOL ProcessCommandLine (PPERF_INFO PerfInfo, unsigned *TestCount, PTEST *Tests)
 
int WINAPI wWinMain (HINSTANCE hInstance, HINSTANCE hPrevInstance, LPWSTR lpszCmdLine, int nCmdShow)
 

Variables

static HWND LabelWnd
 

Macro Definition Documentation

◆ ENOUGH

#define ENOUGH   2000 /* But settle for 2.0 seconds */

◆ GOAL

#define GOAL   2500 /* Try to get up to 2.5 seconds */

◆ MAINWND_HEIGHT

#define MAINWND_HEIGHT   400

Definition at line 51 of file rosperf.c.

◆ MAINWND_WIDTH

#define MAINWND_WIDTH   400

Definition at line 50 of file rosperf.c.

◆ TICK

#define TICK   10 /* Assume clock not faster than .01 seconds */

Function Documentation

◆ CalibrateTest()

static unsigned CalibrateTest ( PTEST  Test,
PPERF_INFO  PerfInfo 
)
static

Definition at line 92 of file rosperf.c.

93{
94#define GOAL 2500 /* Try to get up to 2.5 seconds */
95#define ENOUGH 2000 /* But settle for 2.0 seconds */
96#define TICK 10 /* Assume clock not faster than .01 seconds */
97
98 unsigned Reps, DidReps; /* Reps desired, reps performed */
99 unsigned Exponent;
100 void *Context;
101 DWORD StartTick;
102 DWORD Duration;
103
104 /* Attempt to get an idea how long each rep lasts by getting enough
105 reps to last more than ENOUGH. Then scale that up to the number of
106 seconds desired.
107
108 If init call to test ever fails, return False and test will be skipped.
109 */
110
111 Reps = 1;
112 for (;;)
113 {
114 ClearWindow(PerfInfo);
115 DidReps = (*Test->Init)(&Context, PerfInfo, Reps);
117 if (0 == DidReps)
118 {
119 return 0;
120 }
121 StartTick = GetTickCount();
122 (*Test->Proc)(Context, PerfInfo, Reps);
123 Duration = GetTickCount() - StartTick;
124 (*Test->PassCleanup) (Context, PerfInfo);
125 (*Test->Cleanup)(Context, PerfInfo);
127
128 if (DidReps != Reps)
129 {
130 /* The test can't do the number of reps as we asked for.
131 Give up */
132 return DidReps;
133 }
134 /* Did we go long enough? */
135 if (ENOUGH <= Duration)
136 {
137 break;
138 }
139
140 /* Don't let too short a clock make new reps wildly high */
141 if (Duration <= TICK)
142 {
143 Reps *= 10;
144 }
145 else
146 {
147 /* Try to get up to GOAL seconds. */
148 Reps = (int)(GOAL * (double) Reps / (double) Duration) + 1;
149 }
150 }
151
152 Reps = (int) ((double) PerfInfo->Seconds * 1000.0 * (double) Reps / (double) Duration) + 1;
153
154 /* Now round reps up to 1 digit accuracy, so we don't get stupid-looking
155 numbers of repetitions. */
156 Reps--;
157 Exponent = 1;
158 while (9 < Reps)
159 {
160 Reps /= 10;
161 Exponent *= 10;
162 }
163 Reps = (Reps + 1) * Exponent;
164
165 return Reps;
166}
DWORD WINAPI GetTickCount(VOID)
Definition: time.c:455
unsigned int(__cdecl typeof(jpeg_read_scanlines))(struct jpeg_decompress_struct *
Definition: typeof.h:31
unsigned long DWORD
Definition: ntddk_ex.h:95
static const char mbstate_t *static wchar_t const char mbstate_t *static const wchar_t int *static double
Definition: string.c:80
static void ClearWindow(PPERF_INFO PerfInfo)
Definition: rosperf.c:85
#define GOAL
static void ProcessMessages(void)
Definition: rosperf.c:69
#define TICK
#define ENOUGH
unsigned Seconds
Definition: rosperf.h:25

Referenced by ProcessTest().

◆ ClearWindow()

static void ClearWindow ( PPERF_INFO  PerfInfo)
static

Definition at line 85 of file rosperf.c.

86{
87 InvalidateRect(PerfInfo->Wnd, NULL, TRUE);
88 UpdateWindow(PerfInfo->Wnd);
89}
#define NULL
Definition: types.h:112
#define TRUE
Definition: types.h:120
HWND Wnd
Definition: rosperf.h:24
BOOL WINAPI UpdateWindow(_In_ HWND)
BOOL WINAPI InvalidateRect(_In_opt_ HWND, _In_opt_ LPCRECT, _In_ BOOL)

Referenced by CalibrateTest(), and ProcessTest().

◆ CreatePerfWindows()

static HWND CreatePerfWindows ( HINSTANCE  hInstance,
PPERF_INFO  PerfInfo 
)
static

Definition at line 635 of file rosperf.c.

636{
637 WNDCLASSW wc;
638 HWND MainWnd;
639
640 wc.lpszClassName = L"RosPerfMain";
642 wc.style = 0;
643 wc.hInstance = hInstance;
647 wc.lpszMenuName = NULL;
648 wc.cbClsExtra = 0;
649 wc.cbWndExtra = 0;
650 if (RegisterClassW(&wc) == 0)
651 {
652 fwprintf(stderr, L"Failed to register RosPerfMain (last error %d)\n",
653 GetLastError());
654 return NULL;
655 }
656
657 wc.lpszClassName = L"RosPerfLabel";
659 wc.style = 0;
660 wc.hInstance = hInstance;
664 wc.lpszMenuName = NULL;
665 wc.cbClsExtra = 0;
666 wc.cbWndExtra = 0;
667 if (RegisterClassW(&wc) == 0)
668 {
669 fwprintf(stderr, L"Failed to register RosPerfLabel (last error %d)\n",
670 GetLastError());
671 return NULL;
672 }
673
674 MainWnd = CreateWindowW(L"RosPerfMain",
675 L"ReactOS performance test",
677 0,
678 0,
681 NULL,
682 NULL,
683 hInstance,
684 NULL);
685 if (NULL == MainWnd)
686 {
687 fwprintf(stderr, L"Failed to create main window (last error %d)\n",
688 GetLastError());
689 return NULL;
690 }
691
692 LabelWnd = CreateWindowW(L"RosPerfLabel",
693 L"",
695 0,
696 MAINWND_HEIGHT + 10,
698 20,
699 MainWnd,
700 NULL,
701 hInstance,
702 NULL);
703 if (NULL == LabelWnd)
704 {
705 fwprintf(stderr, L"Failed to create label window (last error 0x%lX)\n",
706 GetLastError());
707 return NULL;
708 }
709
710 SetActiveWindow(MainWnd);
711
712 return MainWnd;
713}
HINSTANCE hInstance
Definition: charmap.c:19
#define stderr
Definition: stdio.h:100
_Check_return_opt_ _CRTIMP int __cdecl fwprintf(_Inout_ FILE *_File, _In_z_ _Printf_format_string_ const wchar_t *_Format,...)
#define L(x)
Definition: ntvdm.h:50
#define WS_OVERLAPPEDWINDOW
Definition: pedump.c:637
#define WS_POPUP
Definition: pedump.c:616
#define WS_VISIBLE
Definition: pedump.c:620
#define WS_THICKFRAME
Definition: pedump.c:630
static LRESULT CALLBACK LabelWndProc(HWND Wnd, UINT Msg, WPARAM wParam, LPARAM lParam)
Definition: rosperf.c:587
#define MAINWND_WIDTH
Definition: rosperf.c:50
static LRESULT CALLBACK MainWndProc(HWND Wnd, UINT Msg, WPARAM wParam, LPARAM lParam)
Definition: rosperf.c:559
static HWND LabelWnd
Definition: rosperf.c:53
#define MAINWND_HEIGHT
Definition: rosperf.c:51
LPCWSTR lpszClassName
Definition: winuser.h:3185
LPCWSTR lpszMenuName
Definition: winuser.h:3184
HBRUSH hbrBackground
Definition: winuser.h:3183
HICON hIcon
Definition: winuser.h:3181
HINSTANCE hInstance
Definition: winuser.h:3180
int cbClsExtra
Definition: winuser.h:3178
UINT style
Definition: winuser.h:3176
WNDPROC lpfnWndProc
Definition: winuser.h:3177
int cbWndExtra
Definition: winuser.h:3179
HCURSOR hCursor
Definition: winuser.h:3182
COLORREF BackgroundColor
Definition: rosperf.h:28
DWORD WINAPI GetLastError(void)
Definition: except.c:1042
HGDIOBJ WINAPI GetStockObject(_In_ int)
#define WHITE_BRUSH
Definition: wingdi.h:902
HBRUSH WINAPI CreateSolidBrush(_In_ COLORREF)
ATOM WINAPI RegisterClassW(_In_ CONST WNDCLASSW *)
#define IDC_ARROW
Definition: winuser.h:687
HCURSOR WINAPI LoadCursorW(_In_opt_ HINSTANCE, _In_ LPCWSTR)
Definition: cursoricon.c:2136
#define IDI_APPLICATION
Definition: winuser.h:704
HWND WINAPI SetActiveWindow(_In_ HWND)
#define CreateWindowW(a, b, c, d, e, f, g, h, i, j, k)
Definition: winuser.h:4316
HICON WINAPI LoadIconW(_In_opt_ HINSTANCE hInstance, _In_ LPCWSTR lpIconName)
Definition: cursoricon.c:2106
const WCHAR * LPCWSTR
Definition: xmlstorage.h:185

Referenced by wWinMain().

◆ DisplayStatus()

static void DisplayStatus ( HWND  Label,
LPCWSTR  Message,
LPCWSTR  Test,
int  Try 
)
static

Definition at line 169 of file rosperf.c.

170{
171 WCHAR Status[128];
172
173 _snwprintf(Status, sizeof(Status) / sizeof(Status[0]), L"%d %s %s", Try, Message, Test);
177}
PWCHAR Label
Definition: format.c:70
static const WCHAR Message[]
Definition: register.c:74
int Try(int arg)
Definition: ehframes.cpp:53
Status
Definition: gdiplustypes.h:25
int _snwprintf(wchar_t *buffer, size_t count, const wchar_t *format,...)
BOOL WINAPI SetWindowTextW(_In_ HWND, _In_opt_ LPCWSTR)
__wchar_t WCHAR
Definition: xmlstorage.h:180

Referenced by ProcessTest().

◆ LabelWndProc()

static LRESULT CALLBACK LabelWndProc ( HWND  Wnd,
UINT  Msg,
WPARAM  wParam,
LPARAM  lParam 
)
static

Definition at line 587 of file rosperf.c.

588{
589 PAINTSTRUCT Ps;
590 HDC Dc;
591 RECT ClientRect, WindowRect;
592 TEXTMETRICW Tm;
594 WCHAR Title[80];
595
596 switch (Msg)
597 {
598 case WM_CREATE:
599 /* Make text fit */
600 Dc = GetDC(Wnd);
601 if (NULL != Dc && GetClientRect(Wnd, &ClientRect) && GetWindowRect(Wnd, &WindowRect)
602 && GetTextMetricsW(Dc, &Tm))
603 {
604 if (Tm.tmHeight != ClientRect.bottom)
605 {
606 SetWindowPos(Wnd, NULL, 0, 0, WindowRect.right - WindowRect.left,
607 (WindowRect.bottom - WindowRect.top) + (Tm.tmHeight - ClientRect.bottom),
609 }
610 }
611 if (NULL != Dc)
612 {
613 ReleaseDC(Wnd, Dc);
614 }
616 break;
617
618 case WM_PAINT:
619 Dc = BeginPaint(Wnd, &Ps);
620 GetWindowTextW(Wnd, Title, sizeof(Title) / sizeof(Title[0]));
621 TextOutW(Dc, 0, 0, Title, wcslen(Title));
622 EndPaint (Wnd, &Ps);
623 Result = 0;
624 break;
625
626 default:
628 break;
629 }
630
631 return Result;
632}
WPARAM wParam
Definition: combotst.c:138
LPARAM lParam
Definition: combotst.c:139
struct @1638 Msg[]
static const WCHAR Title[]
Definition: oid.c:1259
_CRTIMP size_t __cdecl wcslen(_In_z_ const wchar_t *_Str)
static HDC
Definition: imagelist.c:92
LONG right
Definition: windef.h:308
LONG bottom
Definition: windef.h:309
LONG top
Definition: windef.h:307
LONG left
Definition: windef.h:306
LONG tmHeight
Definition: wingdi.h:2383
int WINAPI GetWindowTextW(HWND hWnd, LPWSTR lpString, int nMaxCount)
Definition: window.c:1412
LONG_PTR LRESULT
Definition: windef.h:209
BOOL WINAPI GetTextMetricsW(_In_ HDC, _Out_ LPTEXTMETRICW)
Definition: text.c:221
BOOL WINAPI TextOutW(_In_ HDC hdc, _In_ int x, _In_ int y, _In_reads_(c) LPCWSTR lpString, _In_ int c)
#define WM_PAINT
Definition: winuser.h:1620
int WINAPI ReleaseDC(_In_opt_ HWND, _In_ HDC)
#define SWP_NOACTIVATE
Definition: winuser.h:1242
LRESULT WINAPI DefWindowProcW(_In_ HWND, _In_ UINT, _In_ WPARAM, _In_ LPARAM)
BOOL WINAPI GetWindowRect(_In_ HWND, _Out_ LPRECT)
#define WM_CREATE
Definition: winuser.h:1608
BOOL WINAPI SetWindowPos(_In_ HWND, _In_opt_ HWND, _In_ int, _In_ int, _In_ int, _In_ int, _In_ UINT)
#define SWP_NOMOVE
Definition: winuser.h:1244
BOOL WINAPI GetClientRect(_In_ HWND, _Out_ LPRECT)
BOOL WINAPI EndPaint(_In_ HWND, _In_ const PAINTSTRUCT *)
HDC WINAPI GetDC(_In_opt_ HWND)
#define SWP_NOOWNERZORDER
Definition: winuser.h:1249
#define SWP_NOZORDER
Definition: winuser.h:1247
HDC WINAPI BeginPaint(_In_ HWND, _Out_ LPPAINTSTRUCT)
_At_(*)(_In_ PWSK_CLIENT Client, _In_opt_ PUNICODE_STRING NodeName, _In_opt_ PUNICODE_STRING ServiceName, _In_opt_ ULONG NameSpace, _In_opt_ GUID *Provider, _In_opt_ PADDRINFOEXW Hints, _Outptr_ PADDRINFOEXW *Result, _In_opt_ PEPROCESS OwningProcess, _In_opt_ PETHREAD OwningThread, _Inout_ PIRP Irp Result)(Mem)) NTSTATUS(WSKAPI *PFN_WSK_GET_ADDRESS_INFO
Definition: wsk.h:409

Referenced by CreatePerfWindows().

◆ MainWndProc()

static LRESULT CALLBACK MainWndProc ( HWND  Wnd,
UINT  Msg,
WPARAM  wParam,
LPARAM  lParam 
)
static

Definition at line 559 of file rosperf.c.

560{
561 PAINTSTRUCT Ps;
562 HDC Dc;
564
565 switch (Msg)
566 {
567 case WM_DESTROY:
569 Result = 0;
570 break;
571
572 case WM_PAINT:
573 Dc = BeginPaint(Wnd, &Ps);
574 EndPaint (Wnd, &Ps);
575 Result = 0;
576 break;
577
578 default:
580 break;
581 }
582
583 return Result;
584}
__analysis_noreturn void WINAPI PostQuitMessage(_In_ int)
#define WM_DESTROY
Definition: winuser.h:1609

Referenced by CreatePerfWindows().

◆ NullCleanup()

void NullCleanup ( void Context,
PPERF_INFO  PerfInfo 
)

Definition at line 64 of file rosperf.c.

65{
66}

◆ NullInit()

unsigned NullInit ( void **  Context,
PPERF_INFO  PerfInfo,
unsigned  Reps 
)

Definition at line 56 of file rosperf.c.

57{
58 *Context = NULL;
59
60 return Reps;
61}

◆ PrintAppVersion()

static void PrintAppVersion ( void  )
static

Definition at line 528 of file rosperf.c.

529{
530 wprintf(L"RosPerf %S (Build %S)\n", KERNEL_VERSION_STR, KERNEL_VERSION_BUILD_STR);
531}
#define wprintf(...)
Definition: whoami.c:18

Referenced by PrintStartupInfo().

◆ PrintDisplayInfo()

static void PrintDisplayInfo ( void  )
static

Definition at line 534 of file rosperf.c.

535{
536 HDC Dc;
537
538 Dc = GetDC(NULL);
539 if (NULL == Dc)
540 {
541 return;
542 }
543
544 wprintf(L"Display settings %d * %d * %d\n", GetDeviceCaps(Dc, HORZRES),
546
547 ReleaseDC(NULL, Dc);
548}
#define HORZRES
Definition: wingdi.h:716
int WINAPI GetDeviceCaps(_In_opt_ HDC, _In_ int)
#define VERTRES
Definition: wingdi.h:717
#define PLANES
Definition: wingdi.h:721
#define BITSPIXEL
Definition: wingdi.h:720

Referenced by PrintStartupInfo().

◆ PrintOSVersion()

static void PrintOSVersion ( void  )
static

Definition at line 291 of file rosperf.c.

292{
294 BOOL OsVersionInfoEx;
295 HKEY hKey;
296 WCHAR ProductType[9] = { L'\0' };
297 DWORD BufLen, dwType;
298 LONG Ret;
299 unsigned RosVersionLen;
300 LPWSTR RosVersion;
301
302 /* Try calling GetVersionEx using the OSVERSIONINFOEX structure.
303 * If that fails, try using the OSVERSIONINFO structure. */
304
307
308 OsVersionInfoEx = GetVersionExW((OSVERSIONINFOW *) &VersionInfo);
309 if (! OsVersionInfoEx)
310 {
313 {
314 return;
315 }
316 }
317
319 RosVersionLen = sizeof(VersionInfo.szCSDVersion) / sizeof(VersionInfo.szCSDVersion[0]) -
320 (RosVersion - VersionInfo.szCSDVersion);
321 if (7 <= RosVersionLen && 0 == _wcsnicmp(RosVersion, L"ReactOS", 7))
322 {
323 wprintf(L"Running on %s\n", RosVersion);
324 return;
325 }
326
328 {
329 /* Test for the Windows NT product family. */
331
332 /* Test for the specific product. */
334 {
335 wprintf(L"Running on Microsoft Windows Server 2003, ");
336 }
338 {
339 wprintf(L"Running on Microsoft Windows XP ");
340 }
342 {
343 wprintf(L"Running on Microsoft Windows 2000 ");
344 }
345 else if (VersionInfo.dwMajorVersion <= 4 )
346 {
347 wprintf(L"Running on Microsoft Windows NT ");
348 }
349
350 /* Test for specific product on Windows NT 4.0 SP6 and later. */
351 if (OsVersionInfoEx)
352 {
353 /* Test for the workstation type. */
354 if (VER_NT_WORKSTATION == VersionInfo.wProductType)
355 {
357 {
358 wprintf(L"Workstation 4.0 ");
359 }
360 else if (0 != (VersionInfo.wSuiteMask & VER_SUITE_PERSONAL))
361 {
362 wprintf(L"Home Edition ");
363 }
364 else
365 {
366 wprintf(L"Professional ");
367 }
368 }
369
370 /* Test for the server type. */
371 else if (VER_NT_SERVER == VersionInfo.wProductType ||
373 {
375 {
376 if (0 != (VersionInfo.wSuiteMask & VER_SUITE_DATACENTER))
377 {
378 wprintf(L"Datacenter Edition ");
379 }
380 else if (0 != (VersionInfo.wSuiteMask & VER_SUITE_ENTERPRISE))
381 {
382 wprintf(L"Enterprise Edition ");
383 }
384 else if (VER_SUITE_BLADE == VersionInfo.wSuiteMask)
385 {
386 wprintf(L"Web Edition ");
387 }
388 else
389 {
390 wprintf(L"Standard Edition ");
391 }
392 }
393
395 {
396 if (0 != (VersionInfo.wSuiteMask & VER_SUITE_DATACENTER))
397 {
398 wprintf(L"Datacenter Server ");
399 }
400 else if (0 != (VersionInfo.wSuiteMask & VER_SUITE_ENTERPRISE))
401 {
402 wprintf(L"Advanced Server " );
403 }
404 else
405 {
406 wprintf(L"Server " );
407 }
408 }
409
410 else /* Windows NT 4.0 */
411 {
412 if (0 != (VersionInfo.wSuiteMask & VER_SUITE_ENTERPRISE))
413 {
414 wprintf(L"Server 4.0, Enterprise Edition ");
415 }
416 else
417 {
418 wprintf(L"Server 4.0 ");
419 }
420 }
421 }
422 }
423 else /* Test for specific product on Windows NT 4.0 SP5 and earlier */
424 {
426 L"SYSTEM\\CurrentControlSet\\Control\\ProductOptions",
427 0, KEY_QUERY_VALUE, &hKey);
428 if (ERROR_SUCCESS != Ret)
429 {
430 return;
431 }
432
433 BufLen = sizeof(ProductType);
434 Ret = RegQueryValueExW(hKey, L"ProductType", NULL, &dwType,
435 (LPBYTE) ProductType, &BufLen);
436
438
439 if (Ret != ERROR_SUCCESS || dwType != REG_SZ)
440 {
441 return;
442 }
443
444 if (0 == lstrcmpiW(L"WINNT", ProductType))
445 {
446 wprintf(L"Workstation ");
447 }
448 else if (0 == lstrcmpiW(L"LANMANNT", ProductType))
449 {
450 wprintf(L"Server ");
451 }
452 else if (0 == lstrcmpiW(L"SERVERNT", ProductType))
453 {
454 wprintf(L"Advanced Server ");
455 }
456
458 }
459
460 /* Display service pack (if any) and build number. */
461
462 if (4 == VersionInfo.dwMajorVersion &&
463 0 == lstrcmpiW(VersionInfo.szCSDVersion, L"Service Pack 6"))
464 {
465 /* Test for SP6 versus SP6a. */
467 L"SOFTWARE\\Microsoft\\Windows NT\\CurrentVersion\\Hotfix\\Q246009",
468 0, KEY_QUERY_VALUE, &hKey);
469 if (ERROR_SUCCESS == Ret)
470 {
471 wprintf(L"Service Pack 6a (Build %d)\n", VersionInfo.dwBuildNumber & 0xFFFF);
472 }
473 else /* Windows NT 4.0 prior to SP6a */
474 {
475 wprintf(L"%s (Build %d)\n",
477 VersionInfo.dwBuildNumber & 0xFFFF);
478 }
479
481 }
482 else /* not Windows NT 4.0 */
483 {
484 wprintf(L"%s (Build %d)\n",
486 VersionInfo.dwBuildNumber & 0xFFFF);
487 }
488
489
490 break;
491
492 /* Test for the Windows Me/98/95. A bit silly since we're using Unicode... */
494
496 {
497 wprintf(L"Running on Microsoft Windows 95 ");
498 if (L'C' == VersionInfo.szCSDVersion[1] || L'B' == VersionInfo.szCSDVersion[1])
499 {
500 wprintf(L"OSR2");
501 }
502 }
503
505 {
506 wprintf(L"Running on Microsoft Windows 98 ");
507 if (L'A' == VersionInfo.szCSDVersion[1])
508 {
509 wprintf(L"SE");
510 }
511 }
512
514 {
515 wprintf(L"Running on Microsoft Windows Millennium Edition");
516 }
517 wprintf(L"\n");
518 break;
519
520 case VER_PLATFORM_WIN32s: /* Even silier... */
521
522 wprintf(L"Running on Microsoft Win32s\n");
523 break;
524 }
525}
OSVERSIONINFOW VersionInfo
Definition: wkssvc.c:40
#define RegCloseKey(hKey)
Definition: registry.h:49
#define ERROR_SUCCESS
Definition: deptool.c:10
LONG WINAPI RegOpenKeyExW(HKEY hKey, LPCWSTR lpSubKey, DWORD ulOptions, REGSAM samDesired, PHKEY phkResult)
Definition: reg.c:3333
LONG WINAPI RegQueryValueExW(_In_ HKEY hkeyorg, _In_ LPCWSTR name, _In_ LPDWORD reserved, _In_ LPDWORD type, _In_ LPBYTE data, _In_ LPDWORD count)
Definition: reg.c:4103
BOOL WINAPI GetVersionExW(IN LPOSVERSIONINFOW lpVersionInformation)
Definition: version.c:37
int WINAPI lstrcmpiW(LPCWSTR str1, LPCWSTR str2)
Definition: locale.c:4261
#define BufLen
Definition: fatfs.h:167
unsigned int BOOL
Definition: ntddk_ex.h:94
FxAutoRegKey hKey
#define REG_SZ
Definition: layer.c:22
#define VER_PLATFORM_WIN32_NT
Definition: rtltypes.h:238
#define VER_PLATFORM_WIN32_WINDOWS
Definition: rtltypes.h:237
#define VER_PLATFORM_WIN32s
Definition: rtltypes.h:236
#define KEY_QUERY_VALUE
Definition: nt_native.h:1016
#define VER_SUITE_ENTERPRISE
#define VER_SUITE_DATACENTER
#define VER_SUITE_PERSONAL
#define VER_SUITE_BLADE
long LONG
Definition: pedump.c:60
_Check_return_ _CRTIMP int __cdecl _wcsnicmp(_In_reads_or_z_(_MaxCount) const wchar_t *_Str1, _In_reads_or_z_(_MaxCount) const wchar_t *_Str2, _In_ size_t _MaxCount)
ULONG dwMinorVersion
Definition: rtltypes.h:248
ULONG dwPlatformId
Definition: rtltypes.h:250
ULONG dwOSVersionInfoSize
Definition: rtltypes.h:246
ULONG dwMajorVersion
Definition: rtltypes.h:247
ULONG dwBuildNumber
Definition: rtltypes.h:249
WCHAR szCSDVersion[128]
Definition: rtltypes.h:251
unsigned char * LPBYTE
Definition: typedefs.h:53
#define ZeroMemory
Definition: winbase.h:1712
#define HKEY_LOCAL_MACHINE
Definition: winreg.h:12
#define VER_NT_WORKSTATION
#define VER_NT_SERVER
#define VER_NT_DOMAIN_CONTROLLER
OSVERSIONINFOA OSVERSIONINFO
Definition: rtltypes.h:293
struct _OSVERSIONINFOEXW OSVERSIONINFOEXW
WCHAR * LPWSTR
Definition: xmlstorage.h:184

Referenced by cmd_ver(), PrintPrompt(), and PrintStartupInfo().

◆ PrintStartupInfo()

static void PrintStartupInfo ( void  )
static

Definition at line 551 of file rosperf.c.

552{
556}
static void PrintDisplayInfo(void)
Definition: rosperf.c:534
static void PrintAppVersion(void)
Definition: rosperf.c:528
static void PrintOSVersion(void)
Definition: rosperf.c:291

Referenced by wWinMain().

◆ ProcessCommandLine()

static BOOL ProcessCommandLine ( PPERF_INFO  PerfInfo,
unsigned TestCount,
PTEST Tests 
)
static

Definition at line 716 of file rosperf.c.

717{
718 int ArgC, Arg;
719 LPWSTR *ArgV;
720 LPWSTR EndPtr;
721 PTEST AllTests;
722 BOOL *DoTest;
723 BOOL DoAll;
724 unsigned AllTestCount, i, j;
725
726 ArgV = CommandLineToArgvW(GetCommandLineW(), &ArgC);
727 if (NULL == ArgV)
728 {
729 fwprintf(stderr, L"CommandLineToArgvW failed\n");
730 return FALSE;
731 }
732
733 GetTests(&AllTestCount, &AllTests);
734 DoTest = malloc(AllTestCount * sizeof(BOOL));
735 if (NULL == DoTest)
736 {
737 fwprintf(stderr, L"Out of memory\n");
738 return FALSE;
739 }
740 DoAll = TRUE;
741
742 for (Arg = 1; Arg < ArgC; Arg++)
743 {
744 if (L'/' == ArgV[Arg][0] || L'-' == ArgV[Arg][0])
745 {
746 if (0 == _wcsicmp(ArgV[Arg] + 1, L"repeat"))
747 {
748 if (ArgC <= Arg + 1)
749 {
750 fwprintf(stderr, L"%s needs a repeat count\n", ArgV[Arg]);
751 free(DoTest);
752 GlobalFree(ArgV);
753 return FALSE;
754 }
755 Arg++;
756 PerfInfo->Repeats = wcstoul(ArgV[Arg], &EndPtr, 0);
757 if (L'\0' != *EndPtr || (long) PerfInfo->Repeats <= 0 || ULONG_MAX == PerfInfo->Repeats)
758 {
759 fwprintf(stderr, L"Invalid repeat count %s\n", ArgV[Arg]);
760 free(DoTest);
761 GlobalFree(ArgV);
762 return FALSE;
763 }
764 }
765 else if (0 == _wcsicmp(ArgV[Arg] + 1, L"seconds"))
766 {
767 if (ArgC <= Arg + 1)
768 {
769 fwprintf(stderr, L"%s needs a number of seconds\n", ArgV[Arg]);
770 free(DoTest);
771 GlobalFree(ArgV);
772 return FALSE;
773 }
774 Arg++;
775 PerfInfo->Seconds = wcstoul(ArgV[Arg], &EndPtr, 0);
776 if (L'\0' != *EndPtr || (long) PerfInfo->Seconds < 0 || ULONG_MAX == PerfInfo->Seconds)
777 {
778 fwprintf(stderr, L"Invalid duration %s\n", ArgV[Arg]);
779 free(DoTest);
780 GlobalFree(ArgV);
781 return FALSE;
782 }
783 }
784 else
785 {
786 fwprintf(stderr, L"Unrecognized option %s\n", ArgV[Arg]);
787 free(DoTest);
788 GlobalFree(ArgV);
789 return FALSE;
790 }
791 }
792 else
793 {
794 if (DoAll)
795 {
796 for (i = 0; i < AllTestCount; i++)
797 {
798 DoTest[i] = FALSE;
799 }
800 DoAll = FALSE;
801 }
802 for (i = 0; i < AllTestCount; i++)
803 {
804 if (0 == _wcsicmp(ArgV[Arg], AllTests[i].Option))
805 {
806 DoTest[i] = TRUE;
807 break;
808 }
809 }
810 if (AllTestCount <= i)
811 {
812 fwprintf(stderr, L"Unrecognized test %s\n", ArgV[Arg]);
813 free(DoTest);
814 GlobalFree(ArgV);
815 return FALSE;
816 }
817 }
818 }
819
820 GlobalFree(ArgV);
821
822 if (DoAll)
823 {
824 for (i = 0; i < AllTestCount; i++)
825 {
826 DoTest[i] = TRUE;
827 }
828 }
829
830 *TestCount = 0;
831 for (i = 0; i < AllTestCount; i++)
832 {
833 if (DoTest[i])
834 {
835 (*TestCount)++;
836 }
837 }
838 *Tests = malloc(*TestCount * sizeof(TEST));
839 if (NULL == *Tests)
840 {
841 fwprintf(stderr, L"Out of memory\n");
842 free(DoTest);
843 return FALSE;
844 }
845 j = 0;
846 for (i = 0; i < AllTestCount; i++)
847 {
848 if (DoTest[i])
849 {
850 (*Tests)[j] = AllTests[i];
851 j++;
852 }
853 }
854 free(DoTest);
855
856 return TRUE;
857}
struct test_data Tests[]
#define free
Definition: debug_ros.c:5
#define malloc
Definition: debug_ros.c:4
#define FALSE
Definition: types.h:117
LPWSTR WINAPI GetCommandLineW(VOID)
Definition: proc.c:2013
GLsizei GLenum const GLvoid GLsizei GLenum GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLint GLint GLint GLshort GLshort GLshort GLubyte GLubyte GLubyte GLuint GLuint GLuint GLushort GLushort GLushort GLbyte GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLfloat GLint GLint GLint GLint GLshort GLshort GLshort GLshort GLubyte GLubyte GLubyte GLubyte GLuint GLuint GLuint GLuint GLushort GLushort GLushort GLushort GLboolean const GLdouble const GLfloat const GLint const GLshort const GLbyte const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLdouble const GLfloat const GLfloat const GLint const GLint const GLshort const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort GLenum GLenum GLenum GLfloat GLenum GLint GLenum GLenum GLenum GLfloat GLenum GLenum GLint GLenum GLfloat GLenum GLint GLint GLushort GLenum GLenum GLfloat GLenum GLenum GLint GLfloat const GLubyte GLenum GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLint GLint GLsizei GLsizei GLint GLenum GLenum const GLvoid GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLenum const GLdouble GLenum GLenum const GLfloat GLenum GLenum const GLint GLsizei GLuint GLfloat GLuint GLbitfield GLfloat GLint GLuint GLboolean GLenum GLfloat GLenum GLbitfield GLenum GLfloat GLfloat GLint GLint const GLfloat GLenum GLfloat GLfloat GLint GLint GLfloat GLfloat GLint GLint const GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat const GLdouble const GLfloat const GLdouble const GLfloat GLint i
Definition: glfuncs.h:248
GLsizei GLenum const GLvoid GLsizei GLenum GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLint GLint GLint GLshort GLshort GLshort GLubyte GLubyte GLubyte GLuint GLuint GLuint GLushort GLushort GLushort GLbyte GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLfloat GLint GLint GLint GLint GLshort GLshort GLshort GLshort GLubyte GLubyte GLubyte GLubyte GLuint GLuint GLuint GLuint GLushort GLushort GLushort GLushort GLboolean const GLdouble const GLfloat const GLint const GLshort const GLbyte const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLdouble const GLfloat const GLfloat const GLint const GLint const GLshort const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort GLenum GLenum GLenum GLfloat GLenum GLint GLenum GLenum GLenum GLfloat GLenum GLenum GLint GLenum GLfloat GLenum GLint GLint GLushort GLenum GLenum GLfloat GLenum GLenum GLint GLfloat const GLubyte GLenum GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLint GLint GLsizei GLsizei GLint GLenum GLenum const GLvoid GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLenum const GLdouble GLenum GLenum const GLfloat GLenum GLenum const GLint GLsizei GLuint GLfloat GLuint GLbitfield GLfloat GLint GLuint GLboolean GLenum GLfloat GLenum GLbitfield GLenum GLfloat GLfloat GLint GLint const GLfloat GLenum GLfloat GLfloat GLint GLint GLfloat GLfloat GLint GLint const GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat const GLdouble const GLfloat const GLdouble const GLfloat GLint GLint GLint j
Definition: glfuncs.h:250
HGLOBAL NTAPI GlobalFree(HGLOBAL hMem)
Definition: heapmem.c:611
#define ULONG_MAX
Definition: limits.h:44
_Check_return_ unsigned long __cdecl wcstoul(_In_z_ const wchar_t *_Str, _Out_opt_ _Deref_post_z_ wchar_t **_EndPtr, _In_ int _Radix)
void GetTests(unsigned *TestCount, PTEST *Tests)
Definition: testlist.c:39
_Check_return_ _CRTIMP int __cdecl _wcsicmp(_In_z_ const wchar_t *_Str1, _In_z_ const wchar_t *_Str2)
LPWSTR *WINAPI CommandLineToArgvW(LPCWSTR lpCmdline, int *numargs)
Definition: shell32_main.c:80
Definition: comm.c:65
unsigned Repeats
Definition: rosperf.h:26
VOID DoTest(HWND hWnd)
Definition: winstation.c:143

Referenced by wWinMain().

◆ ProcessMessages()

static void ProcessMessages ( void  )
static

Definition at line 69 of file rosperf.c.

70{
71 MSG Msg;
72
73 while (PeekMessageW(&Msg, NULL, 0, 0, PM_REMOVE))
74 {
75 if (WM_QUIT == Msg.message)
76 {
77 exit(Msg.wParam);
78 }
81 }
82}
#define exit(n)
Definition: config.h:202
TW_UINT32 TW_UINT16 TW_UINT16 MSG
Definition: twain.h:1829
#define WM_QUIT
Definition: winuser.h:1623
BOOL WINAPI TranslateMessage(_In_ const MSG *)
BOOL WINAPI PeekMessageW(_Out_ LPMSG, _In_opt_ HWND, _In_ UINT, _In_ UINT, _In_ UINT)
#define PM_REMOVE
Definition: winuser.h:1196
LRESULT WINAPI DispatchMessageW(_In_ const MSG *)

Referenced by CalibrateTest(), ProcessTest(), and wWinMain().

◆ ProcessTest()

static void ProcessTest ( PTEST  Test,
PPERF_INFO  PerfInfo 
)
static

Definition at line 251 of file rosperf.c.

252{
253 unsigned Reps;
254 unsigned Repeat;
255 void *Context;
256 DWORD StartTick;
257 DWORD Time, TotalTime;
258
259 DisplayStatus(LabelWnd, L"Calibrating", Test->Label, 0);
260 Reps = CalibrateTest(Test, PerfInfo);
261 if (0 == Reps)
262 {
263 return;
264 }
265
266 Reps = Test->Init(&Context, PerfInfo, Reps);
267 if (0 == Reps)
268 {
269 return;
270 }
271 TotalTime = 0;
272 for (Repeat = 0; Repeat < PerfInfo->Repeats; Repeat++)
273 {
274 DisplayStatus(LabelWnd, L"Testing", Test->Label, Repeat + 1);
275 ClearWindow(PerfInfo);
276 StartTick = GetTickCount();
277 (*Test->Proc)(Context, PerfInfo, Reps);
278 Time = GetTickCount() - StartTick;
280 TotalTime += Time;
281 ReportTimes(Time, Reps, Test->Label, FALSE);
282 (*Test->PassCleanup)(Context, PerfInfo);
284 }
285 (*Test->Cleanup)(Context, PerfInfo);
286 ReportTimes(TotalTime, Repeat * Reps, Test->Label, TRUE);
288}
static BOOLEAN Repeat
Definition: dem.c:247
static PLARGE_INTEGER Time
Definition: time.c:105
static void ReportTimes(DWORD Time, int Reps, LPCWSTR Label, BOOL Average)
Definition: rosperf.c:226
static unsigned CalibrateTest(PTEST Test, PPERF_INFO PerfInfo)
Definition: rosperf.c:92
static void DisplayStatus(HWND Label, LPCWSTR Message, LPCWSTR Test, int Try)
Definition: rosperf.c:169

Referenced by wWinMain().

◆ ReportTimes()

static void ReportTimes ( DWORD  Time,
int  Reps,
LPCWSTR  Label,
BOOL  Average 
)
static

Definition at line 226 of file rosperf.c.

227{
228 double MSecsPerObj, ObjsPerSec;
229
230 if (0 != Time)
231 {
232 MSecsPerObj = (double) Time / (double) Reps;
233 ObjsPerSec = (double) Reps * 1000.0 / (double) Time;
234
235 /* Round obj/sec to 3 significant digits. Leave msec untouched, to
236 allow averaging results from several repetitions. */
237 ObjsPerSec = RoundTo3Digits(ObjsPerSec);
238
239 wprintf(L"%7d %s @ %8.4f msec (%8.1f/sec): %s\n",
240 Reps, Average ? L"trep" : L"reps", MSecsPerObj, ObjsPerSec, Label);
241 }
242 else
243 {
244 wprintf(L"%6d %sreps @ 0.0 msec (unmeasurably fast): %s\n",
245 Reps, Average ? L"t" : L"", Label);
246 }
247
248}
static double RoundTo3Digits(double d)
Definition: rosperf.c:180

Referenced by ProcessTest().

◆ RoundTo3Digits()

static double RoundTo3Digits ( double  d)
static

Definition at line 180 of file rosperf.c.

181{
182 /* It's kind of silly to print out things like ``193658.4/sec'' so just
183 junk all but 3 most significant digits. */
184
185 double exponent, sign;
186
187 exponent = 1.0;
188 /* the code below won't work if d should happen to be non-positive. */
189 if (d < 0.0)
190 {
191 d = -d;
192 sign = -1.0;
193 }
194 else
195 {
196 sign = 1.0;
197 }
198
199 if (1000.0 <= d)
200 {
201 do
202 {
203 exponent *= 10.0;
204 }
205 while (1000.0 <= d / exponent);
206 d = (double)((int)(d / exponent + 0.5));
207 d *= exponent;
208 }
209 else
210 {
211 if (0.0 != d)
212 {
213 while (d * exponent < 100.0)
214 {
215 exponent *= 10.0;
216 }
217 }
218 d = (double)((int)(d * exponent + 0.5));
219 d /= exponent;
220 }
221
222 return d * sign;
223}
#define d
Definition: ke_i.h:81
#define sign(x)
Definition: mapdesc.cc:613

Referenced by ReportTimes().

◆ wWinMain()

int WINAPI wWinMain ( HINSTANCE  hInstance,
HINSTANCE  hPrevInstance,
LPWSTR  lpCmdLine,
int  nShowCmd 
)

This file has no copyright assigned and is placed in the Public Domain. This file is part of the w64 mingw-runtime package. No warranty is given; refer to the file DISCLAIMER.PD within this package.

Definition at line 860 of file rosperf.c.

864{
865 PTEST Tests;
866 unsigned TestCount;
867 unsigned CurrentTest;
868 RECT Rect;
869 PERF_INFO PerfInfo;
870
872
873 PerfInfo.Seconds = 15;
874 PerfInfo.Repeats = 4;
875 PerfInfo.ForegroundColor = RGB(0, 0, 0);
876 PerfInfo.BackgroundColor = RGB(255, 255, 255);
877
878 if (! ProcessCommandLine(&PerfInfo, &TestCount, &Tests))
879 {
880 exit(1);
881 }
882
883 PerfInfo.Wnd = CreatePerfWindows(hInstance, &PerfInfo);
884 if (NULL == PerfInfo.Wnd)
885 {
886 exit(1);
887 }
888
889 GetClientRect(PerfInfo.Wnd, &Rect);
890 PerfInfo.WndWidth = Rect.right - Rect.left;
891 PerfInfo.WndHeight = Rect.bottom - Rect.top;
892 PerfInfo.ForegroundDc = GetDC(PerfInfo.Wnd);
893 PerfInfo.BackgroundDc = GetDC(PerfInfo.Wnd);
894 if (NULL == PerfInfo.ForegroundDc || NULL == PerfInfo.BackgroundDc)
895 {
896 fwprintf(stderr, L"Failed to create device contexts (last error %d)\n",
897 GetLastError());
898 exit(1);
899 }
904
906
907 /* Move cursor out of the way */
909 SetCursorPos(Rect.right, Rect.bottom);
910
911 for (CurrentTest = 0; CurrentTest < TestCount; CurrentTest++)
912 {
913 wprintf(L"\n");
914 ProcessTest(Tests + CurrentTest, &PerfInfo);
915 }
916
918
919 return 0;
920}
#define RGB(r, g, b)
Definition: precomp.h:71
static int CurrentTest
Definition: reg.c:155
static void ProcessTest(PTEST Test, PPERF_INFO PerfInfo)
Definition: rosperf.c:251
static BOOL ProcessCommandLine(PPERF_INFO PerfInfo, unsigned *TestCount, PTEST *Tests)
Definition: rosperf.c:716
static HWND CreatePerfWindows(HINSTANCE hInstance, PPERF_INFO PerfInfo)
Definition: rosperf.c:635
static void PrintStartupInfo(void)
Definition: rosperf.c:551
INT WndHeight
Definition: rosperf.h:32
COLORREF ForegroundColor
Definition: rosperf.h:27
HDC BackgroundDc
Definition: rosperf.h:30
HDC ForegroundDc
Definition: rosperf.h:29
INT WndWidth
Definition: rosperf.h:31
HGDIOBJ WINAPI SelectObject(_In_ HDC, _In_ HGDIOBJ)
Definition: dc.c:1539
HPEN WINAPI CreatePen(_In_ int, _In_ int, _In_ COLORREF)
#define PS_SOLID
Definition: wingdi.h:586
BOOL WINAPI SetCursorPos(_In_ int, _In_ int)
Definition: cursoricon.c:2693

Variable Documentation

◆ LabelWnd

HWND LabelWnd
static

Definition at line 53 of file rosperf.c.

Referenced by CreatePerfWindows(), ProcessTest(), and wWinMain().