1 | /* $Id: PrfTstProcess.c,v 1.4 2003-05-01 11:20:50 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 "PrfTiming.h"
|
---|
90 |
|
---|
91 |
|
---|
92 | int main(int argc, char **argv)
|
---|
93 | {
|
---|
94 | long double rdStart;
|
---|
95 | long double rdEnd;
|
---|
96 | int pid;
|
---|
97 | #ifdef __NOTPC__
|
---|
98 | int status;
|
---|
99 | #endif
|
---|
100 |
|
---|
101 | /*
|
---|
102 | * Child process test.
|
---|
103 | */
|
---|
104 | if (argc != 1)
|
---|
105 | return 0;
|
---|
106 |
|
---|
107 | /*
|
---|
108 | * Main process.
|
---|
109 | */
|
---|
110 | rdStart = gettime();
|
---|
111 | #ifndef __NOTPC__
|
---|
112 | pid = spawnl(P_WAIT, argv[0], argv[0], "child", NULL); /* pid == 0 on success */
|
---|
113 | #else
|
---|
114 | pid = fork();
|
---|
115 | if (pid == 0)
|
---|
116 | {/* child code */
|
---|
117 | execl(argv[0], argv[0], "child", NULL);
|
---|
118 | fprintf(stderr, "we should NEVER be here!!\n");
|
---|
119 | return 0;
|
---|
120 | }
|
---|
121 | if (pid > 0)
|
---|
122 | pid = wait(&status);
|
---|
123 | #endif
|
---|
124 | rdEnd = gettime();
|
---|
125 | printf("%Lf - %Lf sec (pid=%x)\n", rdEnd - rdStart, (rdEnd - rdStart) / getHz(), pid);
|
---|
126 | printf("(start: %Lf end: %Lf Hz: %d\n", rdStart, rdEnd, getHz());
|
---|
127 | printSystemInfo();
|
---|
128 | return 0;
|
---|
129 | }
|
---|