/* -*- 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 ***** */
/*
* Test the speed of select within NSPR
*
*/
#include "nspr.h"
#include "prpriv.h"
#include <stdlib.h>
#include <stdio.h>
#include <errno.h>
#include <string.h>
#ifdef XP_MAC
#include "prlog.h"
{
return 0;
}
extern void SetupMacPrintfLog(char *logFile);
#endif
typedef struct timer_slot_t {
unsigned long d_connect;
unsigned long d_cl_data;
unsigned long d_sv_data;
unsigned long d_close;
unsigned long d_total;
unsigned long requests;
} timer_slot_t;
#if defined(XP_MAC)
/*
* Mac does not scale well specially the requirement for thread stack
* space and buffer allocation space. It is easy to get into a fragmented
* buffer.
*/
#else
#endif
static int verbose=0;
static long _thread_exit_count;
void tally_results(int);
/* return the diff in microseconds */
{
/*
* Will C do the right thing with unsigned arithemtic?
*/
}
{
int rem;
int bytes;
if (bytes <= 0)
return -1;
}
return len;
}
void
{
#ifdef DEBUG
#endif
if (_thread_exit_count == 0) {
#ifdef DEBUG
#endif
}
}
void
{
void _client_thread(void *);
int data_buffer_size;
int index;
#ifdef DEBUG
#endif
goto done;
}
goto done;
}
goto done;
}
goto done;
}
goto done;
}
/* Tell the client to start */
id,
0)) == NULL)
#ifdef DEBUG
#endif
start = PR_IntervalNow();
PR_INTERVAL_NO_TIMEOUT)) == NULL) {
goto done;
}
#ifdef DEBUG
#endif
goto done;
}
#ifdef DEBUG
#endif
read_done = PR_IntervalNow();
goto done;
}
#ifdef DEBUG
#endif
write_done = PR_IntervalNow();
close_done = PR_IntervalNow();
#ifdef DEBUG
#endif
}
done:
_thread_exit(*id);
return;
}
void
{
int index;
int data_buffer_size;
int bytes;
#ifdef DEBUG
#endif
goto done;
}
#ifdef DEBUG
#endif
start = PR_IntervalNow();
goto done;
}
#ifdef DEBUG
#endif
PR_INTERVAL_NO_TIMEOUT) < 0) {
goto done;
}
#ifdef DEBUG
#endif
goto done;
}
#ifdef DEBUG
#endif
write_done = PR_IntervalNow();
fprintf(stderr, "Error reading server data for iteration %d in client thread %d (read %d bytes)\n", index, *id, bytes );
goto done;
}
#ifdef DEBUG
#endif
read_done = PR_IntervalNow();
close_done = PR_IntervalNow();
}
done:
_thread_exit(*id);
return;
}
static
void do_work(void)
{
int index;
id,
0)) == NULL)
}
while (_thread_exit_count > 0)
}
static void do_workUU(void)
{
do_work();
}
static void do_workUK(void)
{
do_work();
}
static void do_workKU(void)
{
do_work();
}
static void do_workKK(void)
{
do_work();
}
{
double d;
start = PR_IntervalNow();
(*func)();
stop = PR_IntervalNow();
}
{
#if defined(XP_UNIX) || defined(XP_OS2_EMX)
int opt;
extern char *optarg;
#endif
#if defined(XP_UNIX) || defined(XP_OS2_EMX)
switch(opt) {
case 'i':
break;
case 't':
break;
case 'c':
break;
case 's':
break;
case 'v':
verbose = 1;
break;
default:
break;
}
}
#endif
#ifdef XP_MAC
SetupMacPrintfLog("sel_spd.log");
#endif
return 0;
}
void
{
int index;
unsigned long tot_connect = 0;
unsigned long tot_cl_data = 0;
unsigned long tot_sv_data = 0;
unsigned long tot_close = 0;
unsigned long tot_all = 0;
unsigned long tot_requests = 0;
if (verbose)
}
if (verbose)
}
}