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

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

Initial coding.

File size: 1.8 KB
Line 
1/* $Id: PrfTstProcess.c,v 1.1 2001-07-30 00:43:19 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#include <stdio.h>
12#include <sys\time.h>
13#include <process.h>
14
15
16#ifdef __OS2__
17#define INCL_DOSMISC
18#define INCL_DOSPROFILE
19#include <os2.h>
20
21long double gettime(void)
22{
23#if 0
24 ULONG ul = 0;
25 DosQuerySysInfo(QSV_MS_COUNT, QSV_MS_COUNT, &ul, sizeof(ul));
26#else
27 QWORD qw;
28 DosTmrQueryTime(&qw);
29 return (long double)qw.ulHi * (4294967296.00) + qw.ulLo;
30#endif
31}
32
33unsigned getHz(void)
34{
35#if 0
36 return 1000;
37#else
38 ULONG ul = -1;
39 DosTmrQueryFreq(&ul);
40 return ul;
41#endif
42}
43
44#else
45
46long double gettime(void)
47{
48 struct timeval tp;
49 long sec = 0L;
50
51 if (gettimeofday(&tp, NULL))
52 return -1;
53 return tp.tv_usec / 1000000.00 + tp.tv_sec;
54}
55
56unsigned getHz(void)
57{
58 return 1;//000000;
59}
60
61#endif
62
63
64int main(int argc, char **argv)
65{
66 long double rdStart;
67 long double rdEnd;
68 int pid;
69 #ifndef UNIX
70 #else
71 int status;
72 #endif
73
74 /*
75 * Child process test.
76 */
77 if (argc != 1)
78 return 0;
79
80 /*
81 * Main process.
82 */
83 rdStart = gettime();
84 #ifndef UNIX
85 pid = spawnl(P_WAIT, argv[0], argv[0], "child", NULL);
86 #else
87 pid = fork();
88 if (pid == 0)
89 {/* child code */
90 execl(argv[0], argv[0], "child", NULL);
91 fprintf(stderr, "we should NEVER be here!!\n");
92 return 0;
93 }
94 if (pid > 0)
95 pid = wait(&status);
96 #endif
97 rdEnd = gettime();
98 printf("%Lf - %Lf sec (pid=%x)\n", rdEnd - rdStart, (rdEnd - rdStart) / getHz(), pid);
99 printf("(start: %Lf end: %Lf Hz: %d\n", rdStart, rdEnd, getHz());
100
101 return 0;
102}
Note: See TracBrowser for help on using the repository browser.