3 Copyright (C) Andrew Tridgell 1999
5 This program is free software; you can redistribute it and/or modify
6 it under the terms of the GNU General Public License as published by
7 the Free Software Foundation; either version 2 of the License, or
8 (at your option) any later version.
10 This program is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 GNU General Public License for more details.
15 You should have received a copy of the GNU General Public License
16 along with this program; if not, write to the Free Software
17 Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
22 /* this creates the specified number of child processes and runs fn() in all of them */
23 static double create_procs(int nprocs, void (*fn)(int ))
26 volatile int *child_status;
33 child_status = (volatile int *)shm_setup(sizeof(int)*nprocs);
35 printf("Failed to setup shared memory\n");
39 memset((void *)child_status, 0, sizeof(int)*nprocs);
41 for (i=0;i<nprocs;i++) {
45 child_status[i] = getpid();
47 while (child_status[i]) sleep(1);
49 setbuffer(stdout, NULL, 0);
58 for (i=0;i<nprocs;i++) {
59 if (child_status[i]) synccount++;
61 if (synccount == nprocs) break;
63 } while (end_timer() < 30);
65 if (synccount != nprocs) {
66 printf("FAILED TO START %d CLIENTS (started %d)\n", nprocs, synccount);
70 /* start the client load */
73 for (i=0;i<nprocs;i++) {
77 printf("%d clients started\n", nprocs);
79 for (i=0;i<nprocs;i++) {
80 waitpid(0, &status, 0);
90 int main(int argc, char *argv[])
97 printf("usage: dbench nprocs\n");
101 nprocs = atoi(argv[1]);
107 t = create_procs(nprocs, child_run);
109 /* to produce a netbench result we scale accoding to the
110 netbench measured throughput for the run that produced the
111 sniff that was used to produce client.txt. That run used 2
112 clients and ran for 660 seconds to produce a result of
114 printf("Throughput %g MB/sec (NB=%g MB/sec %g MBit/sec)\n",
115 132*nprocs/t, 0.5*0.5*nprocs*660/t, 2*nprocs*660/t);