thruput.c revision 677833bc953b6cb418c701facbdcf4aa18d6c44e
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/* ***** BEGIN LICENSE BLOCK *****
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
*
* The contents of this file are subject to the Mozilla Public License Version
* 1.1 (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
*
* Software distributed under the License is distributed on an "AS IS" basis,
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
* for the specific language governing rights and limitations under the
* License.
*
* The Original Code is the Netscape Portable Runtime (NSPR).
*
* The Initial Developer of the Original Code is
* Netscape Communications Corporation.
* Portions created by the Initial Developer are Copyright (C) 1998-2000
* the Initial Developer. All Rights Reserved.
*
* Contributor(s):
*
* Alternatively, the contents of this file may be used under the terms of
* either the GNU General Public License Version 2 or later (the "GPL"), or
* the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
* in which case the provisions of the GPL or the LGPL are applicable instead
* of those above. If you wish to allow use of your version of this file only
* under the terms of either the GPL or the LGPL, and not to allow others to
* use your version of this file under the terms of the MPL, indicate your
* decision by deleting the provisions above and replace them with the notice
* and other provisions required by the GPL or the LGPL. If you do not delete
* the provisions above, a recipient may use your version of this file under
* the terms of any one of the MPL, the GPL or the LGPL.
*
* ***** END LICENSE BLOCK ***** */
/*
** File: thruput.c
** Description: Test server's throughput capability comparing various
** implmentation strategies.
**
** Note: Requires a server machine and an aribitrary number of
** clients to bang on it. Trust the numbers on the server
** more than those being displayed by the various clients.
*/
#include "prerror.h"
#include "prinrval.h"
#include "prinit.h"
#include "prio.h"
#include "prlock.h"
#include "prmem.h"
#include "prnetdb.h"
#include "prprf.h"
#include "prthread.h"
#include "pprio.h"
#include "plerror.h"
#include "plgetopt.h"
#define ADDR_BUFFER 100
#define PORT_NUMBER 51877
#define SAMPLING_INTERVAL 10
typedef struct Shared
{
} Shared;
{
char buffer[ADDR_BUFFER];
if (PR_SUCCESS == rv)
return rv;
} /* PrintAddress */
{
(void)PrintAddress(server_address);
do
{
{
return;
}
if (xport_buffer != -1)
{
if (PR_FAILURE == rv)
if (PR_FAILURE == rv)
}
if (PR_FAILURE == rv)
{
if (PR_IO_TIMEOUT_ERROR != PR_GetError())
}
} while (PR_FAILURE == rv);
do
{
now = PR_IntervalNow();
if (interval > sampling_interval)
{
}
if (do_display)
{
}
} while (bytes > 0);
} /* Clientel */
static void Client(const char *server_name)
{
char buffer[PR_NETDB_BUF_SIZE];
if (PR_FAILURE == rv)
else
{
if (PR_EnumerateHostEnt(
else
{
do
{
(void)PR_CreateThread(
{
initial_streams += 1;
}
} while (PR_TRUE);
}
}
}
{
if (xport_buffer != -1)
{
if (PR_FAILURE == rv)
if (PR_FAILURE == rv)
}
do
{
now = PR_IntervalNow();
if (interval > sampling_interval)
{
}
if (do_display)
{
}
} while (bytes > 0);
} /* Servette */
static void Server(void)
{
{
return;
}
else
{
else
{
(void)PrintAddress(&server_address);
do
{
else
{
(void)PrintAddress(&client_address);
(void)PR_CreateThread(
}
} while (PR_TRUE);
}
}
} /* Server */
static void Help(void)
{
} /* Help */
{
const char *server_name = NULL;
{
if (PL_OPT_BAD == os) continue;
{
case 0: /* Name of server */
break;
case 'G': /* Globular threads */
break;
case 'X': /* Use XTP as the transport */
protocol = 36;
break;
case '6': /* Use IPv6 */
break;
case 's': /* initial_streams */
break;
case 'C': /* concurrency */
break;
case 'b': /* buffer size */
break;
case 'B': /* buffer size */
break;
case 'h': /* user wants some guidance */
default:
Help(); /* so give him an earful */
return 2; /* but not a lot else */
}
}
"This machine is %s\n",
"Transport being used is %s\n",
if (PR_GLOBAL_THREAD == thread_scope)
{
if (1 != concurrency)
{
concurrency = 1;
}
}
if (1 != concurrency)
{
}
"All threads will be %s\n",
if (-1 != xport_buffer)
else Client(server_name);
} /* main */
/* thruput.c */