source: branches/libc-0.6/src/emx/testcase/benchmarks/spawnself.c

Last change on this file was 799, checked in by bird, 22 years ago

From win32k.

  • Property cvs2svn:cvs-rev set to 1.1
  • Property svn:eol-style set to native
  • Property svn:executable set to *
  • Property svn:keywords set to Author Date Id Revision
File size: 2.0 KB
Line 
1/* $Id: spawnself.c 799 2003-10-03 19:43:14Z bird $
2 *
3 * Test program which checks how long it takes to execute another
4 * instance of itself and run
5 *
6 * Copyright (c) 2001-2003 knut st. osmundsen (bird@anduin.net)
7 *
8 * GPL
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 *
23 * @subsection Compilation OS/2
24 * Just as normal odin apps:<br>
25 * nmake -f prftstprocess-2.mak
26 * or
27 * wcl386 -d__OS2__=1 -bt=os2v2 /los2v2 -I%WATCOM\h\os2 PrfTstProcess-2.c
28 *
29 * @subsection Complation NT
30 * This works from OS/2 and NT:
31 * wcl386 -d__WINNT__=1 -bt=nt /lnt -I%WATCOM\h\nt PrfTstProcess-2.c kernel32.lib
32 *
33 * Optimized:
34 * wcl386 -Otx -d__WINNT__=1 -bt=nt /lnt -I%WATCOM\h\nt PrfTstProcess-2.c kernel32.lib
35 *
36 */
37
38#include "PrfTiming.h"
39
40
41int main(int argc, char **argv)
42{
43 long double rdCur;
44 long double rdStart;
45 long double rdEnd;
46 unsigned cChilds;
47 int pid;
48 #ifdef __NOTPC__
49 int status;
50 #endif
51
52 /*
53 * Child process test.
54 */
55 if (argc != 1)
56 return 0;
57
58 /*
59 * Main process.
60 */
61 cChilds = 0; /* child count */
62 rdEnd = getHz() * 10.0; /* loop for 10 seconds */
63 rdStart = rdCur = gettime();
64 rdEnd += gettime();
65 while (rdEnd > rdCur)
66 {
67 #ifndef __NOTPC__
68 pid = spawnl(P_WAIT, argv[0], argv[0], "child", NULL); /* pid == 0 on success */
69 #else
70 pid = fork();
71 if (pid == 0)
72 {/* child code */
73 execl(argv[0], argv[0], "child", NULL);
74 fprintf(stderr, "we should NEVER be here!!\n");
75 return 0;
76 }
77 if (pid > 0)
78 pid = wait(&status);
79 #endif
80 cChilds++;
81 rdCur = gettime();
82 }
83 printf("Spawned %d childs in %Lf seconds\n", cChilds, (rdCur - rdStart) / getHz());
84 printSystemInfo();
85 return 0;
86}
Note: See TracBrowser for help on using the repository browser.