summaryrefslogtreecommitdiff
path: root/ACE/performance-tests
diff options
context:
space:
mode:
authorAbdullah Sowayan <sowayan@users.noreply.github.com>2007-08-15 15:58:44 +0000
committerAbdullah Sowayan <sowayan@users.noreply.github.com>2007-08-15 15:58:44 +0000
commita27b85477326c51c075cab79b5a3aa498072f1fd (patch)
tree44899a41fdcd37807b58c9ac937381e5feb33bf0 /ACE/performance-tests
parent963e29b79351de47ac0b963bee4b8fc9843ea38a (diff)
downloadATCD-a27b85477326c51c075cab79b5a3aa498072f1fd.tar.gz
Wed Aug 15 15:56:12 UTC 2007 Abdullah Sowayan <abdullah.sowayan@lmco.com>
Diffstat (limited to 'ACE/performance-tests')
-rw-r--r--ACE/performance-tests/Misc/test_mutex.cpp12
-rw-r--r--ACE/performance-tests/Misc/test_singleton.cpp14
-rw-r--r--ACE/performance-tests/SCTP/Options_Manager.cpp22
-rw-r--r--ACE/performance-tests/Synch-Benchmarks/Perf_Test/condb_test.cpp32
-rw-r--r--ACE/performance-tests/Synch-Benchmarks/Perf_Test/conds_test.cpp32
-rw-r--r--ACE/performance-tests/Synch-Benchmarks/Perf_Test/memory_test.cpp4
-rw-r--r--ACE/performance-tests/Synch-Benchmarks/context.c24
-rw-r--r--ACE/performance-tests/Synch-Benchmarks/synch_driver.cpp2
-rw-r--r--ACE/performance-tests/TTCP/ACE-C++/wrapper-new-ttcp.cpp671
-rw-r--r--ACE/performance-tests/TTCP/C/new-ttcp.cpp764
10 files changed, 801 insertions, 776 deletions
diff --git a/ACE/performance-tests/Misc/test_mutex.cpp b/ACE/performance-tests/Misc/test_mutex.cpp
index 51c0b07a41c..cff5dd76249 100644
--- a/ACE/performance-tests/Misc/test_mutex.cpp
+++ b/ACE/performance-tests/Misc/test_mutex.cpp
@@ -173,10 +173,10 @@ ACE_TMAIN (int argc, ACE_TCHAR *argv[])
ACE_DEBUG ((LM_DEBUG, "Thread_Mutex\n"));
ACE_DEBUG ((LM_DEBUG, "real time = %f secs, user time = %f secs, system time = %f secs\n",
- et.real_time, et.user_time, et.system_time));
+ et.real_time, et.user_time, et.system_time));
ACE_DEBUG ((LM_DEBUG, "time per call = %f usecs\n",
- (et.real_time / double (iterations)) * 1000000));
+ (et.real_time / double (iterations)) * 1000000));
// Test the thread mutex derived (which does use inheritance or
// dynamic binding). Note that we call this via an instance of the
@@ -197,10 +197,10 @@ ACE_TMAIN (int argc, ACE_TCHAR *argv[])
ACE_DEBUG ((LM_DEBUG, "Thread_Mutex_Derived\n"));
ACE_DEBUG ((LM_DEBUG, "real time = %f secs, user time = %f secs, system time = %f secs\n",
- et.real_time, et.user_time, et.system_time));
+ et.real_time, et.user_time, et.system_time));
ACE_DEBUG ((LM_DEBUG, "time per call = %f usecs\n",
- (et.real_time / double (iterations)) * 1000000));
+ (et.real_time / double (iterations)) * 1000000));
// Test the thread mutex derived (which does use inheritance or
// dynamic binding). Note that we call this via a pointer to the
@@ -222,10 +222,10 @@ ACE_TMAIN (int argc, ACE_TCHAR *argv[])
ACE_DEBUG ((LM_DEBUG, "Mutex_Base\n"));
ACE_DEBUG ((LM_DEBUG, "real time = %f secs, user time = %f secs, system time = %f secs\n",
- et.real_time, et.user_time, et.system_time));
+ et.real_time, et.user_time, et.system_time));
ACE_DEBUG ((LM_DEBUG, "time per call = %f usecs\n",
- (et.real_time / double (iterations)) * 1000000));
+ (et.real_time / double (iterations)) * 1000000));
return 0;
}
#else
diff --git a/ACE/performance-tests/Misc/test_singleton.cpp b/ACE/performance-tests/Misc/test_singleton.cpp
index 68d01388766..53790a0fca4 100644
--- a/ACE/performance-tests/Misc/test_singleton.cpp
+++ b/ACE/performance-tests/Misc/test_singleton.cpp
@@ -84,7 +84,7 @@ DC_Singleton::instance (void)
// Perform the Double-Check.
if (DC_Singleton::instance_ == 0)
- ACE_NEW_RETURN (DC_Singleton::instance_, DC_Singleton, 0);
+ ACE_NEW_RETURN (DC_Singleton::instance_, DC_Singleton, 0);
}
return DC_Singleton::instance_;
@@ -117,10 +117,10 @@ ACE_TMAIN (int argc, ACE_TCHAR *argv[])
ACE_DEBUG ((LM_DEBUG, "ACE_Singleton\n"));
ACE_DEBUG ((LM_DEBUG, "real time = %f secs, user time = %f secs, system time = %f secs\n",
- et.real_time, et.user_time, et.system_time));
+ et.real_time, et.user_time, et.system_time));
ACE_DEBUG ((LM_DEBUG, "time per call = %f usecs\n",
- (et.real_time / double (iterations)) * 1000000));
+ (et.real_time / double (iterations)) * 1000000));
// Test the hand-coded Singleton performance (which uses
// Double-Checked Locking).
@@ -136,10 +136,10 @@ ACE_TMAIN (int argc, ACE_TCHAR *argv[])
ACE_DEBUG ((LM_DEBUG, "DC_Singleton\n"));
ACE_DEBUG ((LM_DEBUG, "real time = %f secs, user time = %f secs, system time = %f secs\n",
- et.real_time, et.user_time, et.system_time));
+ et.real_time, et.user_time, et.system_time));
ACE_DEBUG ((LM_DEBUG, "time per call = %f usecs\n",
- (et.real_time / double (iterations)) * 1000000));
+ (et.real_time / double (iterations)) * 1000000));
// Test the Mutex_Singleton implementation (which does not use
// Double-Checked Locking).
@@ -155,10 +155,10 @@ ACE_TMAIN (int argc, ACE_TCHAR *argv[])
ACE_DEBUG ((LM_DEBUG, "Mutex_Singleton\n"));
ACE_DEBUG ((LM_DEBUG, "real time = %f secs, user time = %f secs, system time = %f secs\n",
- et.real_time, et.user_time, et.system_time));
+ et.real_time, et.user_time, et.system_time));
ACE_DEBUG ((LM_DEBUG, "time per call = %f usecs\n",
- (et.real_time / double (iterations)) * 1000000));
+ (et.real_time / double (iterations)) * 1000000));
return 0;
}
diff --git a/ACE/performance-tests/SCTP/Options_Manager.cpp b/ACE/performance-tests/SCTP/Options_Manager.cpp
index 6d28a393fdf..679249ebf15 100644
--- a/ACE/performance-tests/SCTP/Options_Manager.cpp
+++ b/ACE/performance-tests/SCTP/Options_Manager.cpp
@@ -477,8 +477,8 @@ void Options_Manager::_show_usage(FILE* out, ACE_TCHAR const * const opts_set)
if (!ACE_OS::strcmp (ACE_TEXT ("client-opts"), opts_set)){
ACE_OS::fprintf (out, " Flag Args Option-Name Default\n"
- " -c int test-iterations 1000000\n"
- " -n none test-enable-nagle NO NAGLING\n");
+ " -c int test-iterations 1000000\n"
+ " -n none test-enable-nagle NO NAGLING\n");
if (ACE_OS::strstr(__program_name, ACE_TEXT ("SOCK_STREAM_clt"))) {
ACE_OS::fprintf (out, " -t str (sctp|tcp) test-transport-protocol sctp\n");
}
@@ -486,19 +486,19 @@ void Options_Manager::_show_usage(FILE* out, ACE_TCHAR const * const opts_set)
ACE_OS::fprintf (out, "\n");
ACE_OS::fprintf (out, " -m dbl histogram-min-bin 0\n"
- " -M dbl histogram-max-bin 10000\n"
- " -x int histogram-num-outliers 100\n"
- " -b int histogram-bin-count 1000\n");
+ " -M dbl histogram-max-bin 10000\n"
+ " -x int histogram-num-outliers 100\n"
+ " -b int histogram-bin-count 1000\n");
ACE_OS::fprintf (out, "\n");
ACE_OS::fprintf (out, " -C int client-port assigned by kernel\n"
- " -i str client-connect-addr INADDR_ANY\n");
+ " -i str client-connect-addr INADDR_ANY\n");
ACE_OS::fprintf (out, "\n");
ACE_OS::fprintf (out, " -p int server-port 45453\n"
- " -H str server-host localhost\n");
+ " -H str server-host localhost\n");
ACE_OS::fprintf (out, "\n");
@@ -512,7 +512,7 @@ void Options_Manager::_show_usage(FILE* out, ACE_TCHAR const * const opts_set)
} else if (!ACE_OS::strcmp(ACE_TEXT ("server-opts"), opts_set)){
ACE_OS::fprintf (out, " Flag Args Option-Name Default\n"
- " -n none test-enable-nagle NO NAGLING\n");
+ " -n none test-enable-nagle NO NAGLING\n");
if (ACE_OS::strstr(__program_name, ACE_TEXT ("SOCK_STREAM_srv"))) {
ACE_OS::fprintf (out, " -t str (sctp|tcp) test-transport-protocol sctp\n");
}
@@ -523,9 +523,9 @@ void Options_Manager::_show_usage(FILE* out, ACE_TCHAR const * const opts_set)
if (ACE_OS::strstr(__program_name, ACE_TEXT ("SOCK_SEQPACK_srv"))) {
ACE_OS::fprintf (out, " -a w.x.y.z,a.b.c.d,... server-accept-addr INADDR_ANY\n"
- " (comma-separated \n"
- " list of one or more \n"
- " addresses) \n");
+ " (comma-separated \n"
+ " list of one or more \n"
+ " addresses) \n");
} else {
ACE_OS::fprintf (out, " -a w.x.y.z server-accept-addr INADDR_ANY\n");
}
diff --git a/ACE/performance-tests/Synch-Benchmarks/Perf_Test/condb_test.cpp b/ACE/performance-tests/Synch-Benchmarks/Perf_Test/condb_test.cpp
index 432f741b9e7..9c0a09534e2 100644
--- a/ACE/performance-tests/Synch-Benchmarks/Perf_Test/condb_test.cpp
+++ b/ACE/performance-tests/Synch-Benchmarks/Perf_Test/condb_test.cpp
@@ -36,26 +36,26 @@ Cond_Brdcast_Test::svc (void)
if (ni == 4)
while (!this->done ())
{
- mutex.acquire ();
- while (resources > 0)
- notfull.wait ();
- performance_test_options.thr_work_count[ni]++;
- resources = performance_test_options.thr_count () - 1;
- buffer++;
- notempty.broadcast ();
- mutex.release ();
+ mutex.acquire ();
+ while (resources > 0)
+ notfull.wait ();
+ performance_test_options.thr_work_count[ni]++;
+ resources = performance_test_options.thr_count () - 1;
+ buffer++;
+ notempty.broadcast ();
+ mutex.release ();
}
else
while (!this->done ())
{
- mutex.acquire ();
- while (resources == 0)
- notempty.wait ();
- performance_test_options.thr_work_count[ni]++;
- buffer++;
- if (--resources == 0)
- notfull.signal ();
- mutex.release ();
+ mutex.acquire ();
+ while (resources == 0)
+ notempty.wait ();
+ performance_test_options.thr_work_count[ni]++;
+ buffer++;
+ if (--resources == 0)
+ notfull.signal ();
+ mutex.release ();
}
/* NOTREACHED */
diff --git a/ACE/performance-tests/Synch-Benchmarks/Perf_Test/conds_test.cpp b/ACE/performance-tests/Synch-Benchmarks/Perf_Test/conds_test.cpp
index a930727861b..a30b67c040f 100644
--- a/ACE/performance-tests/Synch-Benchmarks/Perf_Test/conds_test.cpp
+++ b/ACE/performance-tests/Synch-Benchmarks/Perf_Test/conds_test.cpp
@@ -37,28 +37,28 @@ Cond_Signal_Test::svc (void)
if (ni == 4)
while (!this->done ())
{
- mutex.acquire ();
+ mutex.acquire ();
- while (resources > 0)
- notfull.wait ();
+ while (resources > 0)
+ notfull.wait ();
- performance_test_options.thr_work_count[ni]++;
- resources = performance_test_options.thr_count () - 1;
- buffer++;
- notempty.signal ();
- mutex.release ();
+ performance_test_options.thr_work_count[ni]++;
+ resources = performance_test_options.thr_count () - 1;
+ buffer++;
+ notempty.signal ();
+ mutex.release ();
}
else
while (!this->done ())
{
- mutex.acquire ();
- while (resources == 0)
- notempty.wait ();
- performance_test_options.thr_work_count[ni]++;
- buffer++;
- if (--resources == 0)
- notfull.signal ();
- mutex.release ();
+ mutex.acquire ();
+ while (resources == 0)
+ notempty.wait ();
+ performance_test_options.thr_work_count[ni]++;
+ buffer++;
+ if (--resources == 0)
+ notfull.signal ();
+ mutex.release ();
}
/* NOTREACHED */
diff --git a/ACE/performance-tests/Synch-Benchmarks/Perf_Test/memory_test.cpp b/ACE/performance-tests/Synch-Benchmarks/Perf_Test/memory_test.cpp
index 9d0bcd6c7d1..ff62b5e3a2a 100644
--- a/ACE/performance-tests/Synch-Benchmarks/Perf_Test/memory_test.cpp
+++ b/ACE/performance-tests/Synch-Benchmarks/Perf_Test/memory_test.cpp
@@ -21,8 +21,8 @@ Memory_Test::svc (void)
{
int ni = this->thr_id ();
size_t length = performance_test_options.msg_size ();
- char *from = new char[length];
- char *to = new char[length];
+ char *from = new char[length];
+ char *to = new char[length];
synch_count = 1;
diff --git a/ACE/performance-tests/Synch-Benchmarks/context.c b/ACE/performance-tests/Synch-Benchmarks/context.c
index a2ce1c580e9..00850fda8e9 100644
--- a/ACE/performance-tests/Synch-Benchmarks/context.c
+++ b/ACE/performance-tests/Synch-Benchmarks/context.c
@@ -1,6 +1,6 @@
/* $Id$ */
#include <stdio.h>
-// @(#)context.c 1.1 10/18/96
+// @(#)context.c 1.1 10/18/96
#include <stdlib.h>
#include <thread.h>
@@ -59,15 +59,15 @@ main (int argc, char *argv[])
rate = (count[0] + count[1]) / ((float) NSLEEP);
printf ("\n------------------------------------------------------------------------\n");
printf ("t0arg 0x%x (%s, %s, %s)\nt1arg 0x%x (%s, %s, %s)\ncount[0] %d count[1] %d\n\
-ncorr_orig %d ncorr_set %d ncorr_end %d rate %.3f per_cxt %.2f usec\n",
- t0arg,
- (t0arg & THR_DETACHED) ? "THR_DETACHED" : "Not Detached",
- (t0arg & THR_BOUND) ? "THR_BOUND" : "Not Bound",
- (t0arg & THR_NEW_LWP) ? "THR_NEW_LWP" : "No New_LWP",
- t1arg,
- (t1arg & THR_DETACHED) ? "THR_DETACHED" : "Not Detached",
- (t1arg & THR_BOUND) ? "THR_BOUND" : "Not Bound",
- (t1arg & THR_NEW_LWP) ? "THR_NEW_LWP" : "No New_LWP",
- count[0], count[1],
- orig_ncorr, ncorr, thr_getconcurrency (), rate, 1.0e6 / rate);
+ ncorr_orig %d ncorr_set %d ncorr_end %d rate %.3f per_cxt %.2f usec\n",
+ t0arg,
+ (t0arg & THR_DETACHED) ? "THR_DETACHED" : "Not Detached",
+ (t0arg & THR_BOUND) ? "THR_BOUND" : "Not Bound",
+ (t0arg & THR_NEW_LWP) ? "THR_NEW_LWP" : "No New_LWP",
+ t1arg,
+ (t1arg & THR_DETACHED) ? "THR_DETACHED" : "Not Detached",
+ (t1arg & THR_BOUND) ? "THR_BOUND" : "Not Bound",
+ (t1arg & THR_NEW_LWP) ? "THR_NEW_LWP" : "No New_LWP",
+ count[0], count[1],
+ orig_ncorr, ncorr, thr_getconcurrency (), rate, 1.0e6 / rate);
}
diff --git a/ACE/performance-tests/Synch-Benchmarks/synch_driver.cpp b/ACE/performance-tests/Synch-Benchmarks/synch_driver.cpp
index eca2f6cecb0..4fb02007eb0 100644
--- a/ACE/performance-tests/Synch-Benchmarks/synch_driver.cpp
+++ b/ACE/performance-tests/Synch-Benchmarks/synch_driver.cpp
@@ -47,6 +47,6 @@ int
ACE_TMAIN (int, ACE_TCHAR *[])
{
ACE_ERROR_RETURN ((LM_ERROR,
- "This test requires the platform to have threads\n"), -1);
+ "This test requires the platform to have threads\n"), -1);
}
#endif /* ACE_HAS_THREADS */
diff --git a/ACE/performance-tests/TTCP/ACE-C++/wrapper-new-ttcp.cpp b/ACE/performance-tests/TTCP/ACE-C++/wrapper-new-ttcp.cpp
index c195836c890..bbf18cf4b5e 100644
--- a/ACE/performance-tests/TTCP/ACE-C++/wrapper-new-ttcp.cpp
+++ b/ACE/performance-tests/TTCP/ACE-C++/wrapper-new-ttcp.cpp
@@ -66,7 +66,7 @@
#include <netinet/tcp.h>
#include <arpa/inet.h>
#include <netdb.h>
-#include <sys/time.h> /* struct itimerval */
+#include <sys/time.h> /* struct itimerval */
#include <limits.h>
#include <sys/un.h>
#include <unistd.h>
@@ -114,33 +114,33 @@ struct Data_Control_Message
int fromlen;
int domain = PF_INET; /* Default is to use Internet domain sockets. */
-char *domainname; /* Rendezvous address for UNIX domain sockets. */
-int fd; /* fd of network socket */
+char *domainname; /* Rendezvous address for UNIX domain sockets. */
+int fd; /* fd of network socket */
int data_buf_len = 1024 * 1024 * 2; // length of data portion
-long total_msg_len; // length of entire message
-char *data_buf; // pointer to data portion
-int nbuf = 2 * 1024; /* number of buffers to send in sinkmode */
-
-int bufoffset = 0; /* align buffer to this */
-int bufalign = 16 * 1024; /* modulo this */
-
-int udp = 0; /* 0 = tcp, !0 = udp */
-int options = 0; /* socket options */
-int one = 1; /* for 4.3 BSD style setsockopt() */
-short port = 5001; /* TCP port number */
-char *host; /* ptr to name of host */
-int trans; /* 0=receive, !0=transmit mode */
-int sinkmode = 0; /* 0=normal I/O, !0=sink/source mode */
-int verbose = 0; /* 0=print basic info, 1=print cpu rate, proc
- * resource usage. */
-int nodelay = 0; /* set TCP_NODELAY socket option */
-int b_flag = 0; /* use mread() */
-int sockbufsize = 0; /* socket buffer size to use */
-char fmt = 'K'; /* output format: k = kilobits, K = kilobytes,
- * m = megabits, M = megabytes,
- * g = gigabits, G = gigabytes */
-int touchdata = 0; /* access data after reading */
+long total_msg_len; // length of entire message
+char *data_buf; // pointer to data portion
+int nbuf = 2 * 1024; /* number of buffers to send in sinkmode */
+
+int bufoffset = 0; /* align buffer to this */
+int bufalign = 16 * 1024; /* modulo this */
+
+int udp = 0; /* 0 = tcp, !0 = udp */
+int options = 0; /* socket options */
+int one = 1; /* for 4.3 BSD style setsockopt() */
+short port = 5001; /* TCP port number */
+char *host; /* ptr to name of host */
+int trans; /* 0=receive, !0=transmit mode */
+int sinkmode = 0; /* 0=normal I/O, !0=sink/source mode */
+int verbose = 0; /* 0=print basic info, 1=print cpu rate, proc
+ * resource usage. */
+int nodelay = 0; /* set TCP_NODELAY socket option */
+int b_flag = 0; /* use mread() */
+int sockbufsize = 0; /* socket buffer size to use */
+char fmt = 'K'; /* output format: k = kilobits, K = kilobytes,
+ * m = megabits, M = megabytes,
+ * g = gigabits, G = gigabytes */
+int touchdata = 0; /* access data after reading */
struct hostent *addr;
extern int errno;
@@ -153,7 +153,7 @@ Usage: ttcp -t [-options] host [ < in ]\n\
Common options:\n\
-l ## length of bufs read from or written to network (default 8192)\n\
-u use UDP instead of TCP\n\
- -U use UNIX domain sockets instead of Internet domain sockets\n\
+ -U use UNIX domain sockets instead of Internet domain sockets\n\
-p ## port number to send to or listen at (default 5001)\n\
-s -t: source a pattern to network\n\
-r: sink (discard) all data from network\n\
@@ -172,9 +172,9 @@ Options specific to -r:\n\
";
char stats[128];
-unsigned long nbytes; /* bytes on net */
-unsigned long numCalls = 0; /* # of I/O system calls */
-double cput, realt; /* user, real time (seconds) */
+unsigned long nbytes; /* bytes on net */
+unsigned long numCalls = 0; /* # of I/O system calls */
+double cput, realt; /* user, real time (seconds) */
void err (char *s);
void mes (char *s);
@@ -228,82 +228,82 @@ main (int argc, char *argv[])
while ((c = getopt (argc, argv, "drstU:uvBDTb:f:l:n:p:A:O:L:xh:")) != -1)
{
switch (c)
- {
-
- case 'h':
- host = optarg;
+ {
+ case 'h':
+ host = optarg;
+ break;
+ case 'x':
+ new_line = 1;
+ break;
+ case 'L':
+ title = optarg;
+ break;
+ case 'B':
+ b_flag = 1;
+ break;
+ case 't':
+ trans = 1;
+ break;
+ case 'r':
+ trans = 0;
+ break;
+ case 'd':
+ options |= SO_DEBUG;
+ break;
+ case 'D':
+ #ifdef TCP_NODELAY
+ nodelay = 1;
+ #else
+ fprintf (stderr,
+ "ttcp: -D option ignored: TCP_NODELAY socket option not supported\n");
+ #endif
+ break;
+ case 'n':
+ nbuf = atoi (optarg);
+ break;
+ case 'l':
+ data_buf_len = atoi (optarg);
+ break;
+ case 's':
+ sinkmode = !sinkmode;
+ break;
+ case 'p':
+ port = atoi (optarg);
break;
- case 'x':
- new_line = 1;
- break;
- case 'L':
- title = optarg;
- break;
- case 'B':
- b_flag = 1;
- break;
- case 't':
- trans = 1;
- break;
- case 'r':
- trans = 0;
- break;
- case 'd':
- options |= SO_DEBUG;
- break;
- case 'D':
-#ifdef TCP_NODELAY
- nodelay = 1;
-#else
- fprintf (stderr,
- "ttcp: -D option ignored: TCP_NODELAY socket option not supported\n");
-#endif
- break;
- case 'n':
- nbuf = atoi (optarg);
- break;
- case 'l':
- data_buf_len = atoi (optarg);
- break;
- case 's':
- sinkmode = !sinkmode;
- break;
- case 'p':
- port = atoi (optarg);
- break;
case 'U':
- domain = PF_UNIX;
- domainname = optarg;
- break;
- case 'u':
- udp = 1;
- break;
- case 'v':
- verbose = 1;
- break;
- case 'A':
- bufalign = atoi (optarg);
- break;
- case 'O':
- bufoffset = atoi (optarg);
- break;
- case 'b':
-#if defined(SO_SNDBUF) || defined(SO_RCVBUF)
- sockbufsize = atoi (optarg);
-#else
- fprintf (stderr, "ttcp: -b option ignored: SO_SNDBUF/SO_RCVBUF socket options not supported\n");
-#endif
- break;
- case 'f':
- fmt = *optarg;
- break;
- case 'T':
- touchdata = 1;
- break;
-
- default:
- goto usage;
- }
+ domain = PF_UNIX;
+ domainname = optarg;
+ break;
+ case 'u':
+ udp = 1;
+ break;
+ case 'v':
+ verbose = 1;
+ break;
+ case 'A':
+ bufalign = atoi (optarg);
+ break;
+ case 'O':
+ bufoffset = atoi (optarg);
+ break;
+ case 'b':
+ #if defined(SO_SNDBUF) || defined(SO_RCVBUF)
+ sockbufsize = atoi (optarg);
+ #else
+ fprintf (stderr,
+ "ttcp: -b option ignored: SO_SNDBUF/SO_RCVBUF socket options not supported\n");
+ #endif
+ break;
+ case 'f':
+ fmt = *optarg;
+ break;
+ case 'T':
+ touchdata = 1;
+ break;
+
+ default:
+ goto usage;
+ }
}
/* if transmitter, create remote address to transmit to. */
@@ -311,7 +311,7 @@ main (int argc, char *argv[])
if (trans)
{
if (address.set (port, host) == -1)
- perror ("address.set"), exit (1);
+ perror ("address.set"), exit (1);
}
/* else, receiver create address to listen on */
@@ -343,21 +343,21 @@ main (int argc, char *argv[])
if (trans)
{
fprintf (stdout,
- "ttcp-t: data_buf_len=%d, nbuf=%d, align=%d/%d, port=%d",
- data_buf_len, nbuf, bufalign, bufoffset, port);
+ "ttcp-t: data_buf_len=%d, nbuf=%d, align=%d/%d, port=%d",
+ data_buf_len, nbuf, bufalign, bufoffset, port);
if (sockbufsize)
- fprintf (stdout, ", sockbufsize=%d", sockbufsize);
+ fprintf (stdout, ", sockbufsize=%d", sockbufsize);
fprintf (stdout, " %s -> %s\n",
- domain == PF_INET ? (udp ? "udp" : "tcp") : "unix",
- host == 0 ? domainname : host);
+ domain == PF_INET ? (udp ? "udp" : "tcp") : "unix",
+ host == 0 ? domainname : host);
}
else // receiver
{
fprintf (stdout,
- "ttcp-r: data_buf_len=%d, nbuf=%d, align=%d/%d, port=%d",
- data_buf_len, nbuf, bufalign, bufoffset, port);
+ "ttcp-r: data_buf_len=%d, nbuf=%d, align=%d/%d, port=%d",
+ data_buf_len, nbuf, bufalign, bufoffset, port);
if (sockbufsize)
- fprintf (stdout, ", sockbufsize=%d", sockbufsize);
+ fprintf (stdout, ", sockbufsize=%d", sockbufsize);
fprintf (stdout, " %s\n", domain == PF_INET ? (udp ? "udp" : "tcp") : "unix");
}
@@ -373,62 +373,64 @@ main (int argc, char *argv[])
/* the transmitter will set options and connect to receiver */
if (trans)
- {
- // turn off weird ack things
- if (nodelay)
- {
- struct protoent *p = getprotobyname ("tcp");
-
- if (p && connection_stream.set_option (p->p_proto,
- TCP_NODELAY,
- (char *)& one,
- sizeof (one)))
- err ("setsockopt: nodelay");
- mes ("nodelay");
- }
- if (connector_factory.connect (connection_stream, address) == -1)
- perror ("connection failed"), exit (1);
- fprintf (stdout,
- "ttcp-t: data_buf_len=%d, nbuf=%d, align=%d/%d, port=%d",
- data_buf_len, nbuf, bufalign, bufoffset, port);
-
- if (sockbufsize)
- {
- if (connection_stream.set_option (SOL_SOCKET,
- SO_SNDBUF,
- (char *) &sockbufsize,
- sizeof sockbufsize) == -1)
- err ("acceptor_factory.set_option");
- mes ("sndbuf");
- }
- }
+ {
+ // turn off weird ack things
+ if (nodelay)
+ {
+ struct protoent *p = getprotobyname ("tcp");
+
+ if (p && connection_stream.set_option (p->p_proto,
+ TCP_NODELAY,
+ (char *)& one,
+ sizeof (one)))
+ err ("setsockopt: nodelay");
+ mes ("nodelay");
+ }
+ if (connector_factory.connect (connection_stream, address) == -1)
+ perror ("connection failed"), exit (1);
+ fprintf (stdout,
+ "ttcp-t: data_buf_len=%d, nbuf=%d, align=%d/%d, port=%d",
+ data_buf_len, nbuf, bufalign, bufoffset, port);
+
+ if (sockbufsize)
+ {
+ if (connection_stream.set_option (SOL_SOCKET,
+ SO_SNDBUF,
+ (char *) &sockbufsize,
+ sizeof sockbufsize) == -1)
+ err ("acceptor_factory.set_option");
+ mes ("sndbuf");
+ }
+ }
/* receiver will listen for connections from the transmitter */
else
- {
- if (acceptor_factory.open (address, 1) == -1)
- perror ("acceptor open"), exit (1);
-
- if (sockbufsize)
- {
- if (connection_stream.set_option (SOL_SOCKET,
- SO_RCVBUF,
- (char *) &sockbufsize,
- sizeof sockbufsize) == -1)
- err ("acceptor_factory.set_option");
- mes ("rcvbuf");
- }
-
- ACE_INET_Addr remote_address;
-
- if (acceptor_factory.accept (connection_stream,
- (ACE_Addr *) &remote_address) == -1)
- perror ("acceptor accept"), exit (1);
-
- // set the window size
-
- fprintf (stderr, "ttcp-r: accept from %s\n", remote_address.get_host_name());
- }
+ {
+ if (acceptor_factory.open (address, 1) == -1)
+ perror ("acceptor open"), exit (1);
+
+ if (sockbufsize)
+ {
+ if (connection_stream.set_option (SOL_SOCKET,
+ SO_RCVBUF,
+ (char *) &sockbufsize,
+ sizeof sockbufsize) == -1)
+ err ("acceptor_factory.set_option");
+ mes ("rcvbuf");
+ }
+
+ ACE_INET_Addr remote_address;
+
+ if (acceptor_factory.accept (connection_stream,
+ (ACE_Addr *) &remote_address) == -1)
+ perror ("acceptor accept"), exit (1);
+
+ // set the window size
+
+ fprintf (stderr,
+ "ttcp-r: accept from %s\n",
+ remote_address.get_host_name());
+ }
}
//
@@ -442,48 +444,53 @@ main (int argc, char *argv[])
prep_timer ();
ACE_DEBUG ((LM_DEBUG, "Sending session control message"
- " nbuf %d, size %d\n", session_control_buf.nbuf_,
- session_control_buf.size_));
+ " nbuf %d, size %d\n", session_control_buf.nbuf_,
+ session_control_buf.size_));
if (connection_stream.send_n ((char *) &session_control_buf,
- sizeof (Session_Control_Message))
- != sizeof (Session_Control_Message))
- ACE_ERROR_RETURN ((LM_ERROR, "%p send session control failed\n",
- "ttcp"), -1);
+ sizeof (Session_Control_Message))
+ != sizeof (Session_Control_Message))
+ ACE_ERROR_RETURN ((LM_ERROR,
+ "%p send session control failed\n",
+ "ttcp"),
+ -1);
long ack;
int send_result;
while (nbuf--)
- {
- send_result = connection_stream.send_n ((char *) message_buf, total_msg_len);
- if (send_result != total_msg_len)
- ACE_ERROR_RETURN ((LM_ERROR, "%p only sent %d of %d bytes on call %d\n",
- "ttcp", send_result, total_msg_len, numCalls + 1), -1);
- numCalls++;
- nbytes += data_buf_len;
-
- if (connection_stream.recv_n ((char *) &ack, sizeof ack)
- != sizeof ack)
- ACE_ERROR_RETURN ((LM_ERROR, "%p recv of ack failed\n",
- "ttcp"), -1);
-
- if (ack != data_buf_len)
- ACE_DEBUG ((LM_DEBUG, "received ack for only %d bytes\n", ack));
- }
- printf("Client finished. \n");
+ {
+ send_result = connection_stream.send_n ((char *) message_buf,
+ total_msg_len);
+ if (send_result != total_msg_len)
+ ACE_ERROR_RETURN ((LM_ERROR,
+ "%p only sent %d of %d bytes on call %d\n",
+ "ttcp", send_result, total_msg_len, numCalls + 1),
+ -1);
+ numCalls++;
+ nbytes += data_buf_len;
+
+ if (connection_stream.recv_n ((char *) &ack, sizeof ack) != sizeof ack)
+ ACE_ERROR_RETURN ((LM_ERROR, "%p recv of ack failed\n", "ttcp"), -1);
+
+ if (ack != data_buf_len)
+ ACE_DEBUG ((LM_DEBUG, "received ack for only %d bytes\n", ack));
+ }
+ printf("Client finished. \n");
}
else
{
prep_timer ();
if (connection_stream.recv_n ((char *) &session_control_buf,
- sizeof (Session_Control_Message))
- != sizeof (Session_Control_Message))
- ACE_ERROR_RETURN ((LM_ERROR, "%p recv session control failed\n",
- "ttcp"), -1);
+ sizeof (Session_Control_Message))
+ != sizeof (Session_Control_Message))
+ ACE_ERROR_RETURN ((LM_ERROR,
+ "%p recv session control failed\n",
+ "ttcp"),
+ -1);
ACE_DEBUG ((LM_DEBUG, "received session control message"
- " nbuf %d, size %d\n", session_control_buf.nbuf_,
- session_control_buf.size_));
+ " nbuf %d, size %d\n", session_control_buf.nbuf_,
+ session_control_buf.size_));
nbuf = session_control_buf.nbuf_;
// ignore session_control_buf.size_ for now
@@ -491,25 +498,29 @@ main (int argc, char *argv[])
long cnt;
while (nbuf--)
- {
- if (connection_stream.recv_n ((char *) message_buf, sizeof (long))
- != sizeof (long))
- ACE_ERROR_RETURN ((LM_ERROR, "%p recv data control failed\n",
- "ttcp"), -1);
-
- cnt = connection_stream.recv_n (& (message_buf->data_), message_buf->size_);
- if (cnt != message_buf->size_)
- ACE_ERROR_RETURN ((LM_ERROR, "recv data failed\n"), -1);
-
- numCalls++;
- nbytes += cnt;
-
- if (connection_stream.send_n ((char *) &cnt, sizeof cnt)
- != sizeof cnt)
- ACE_ERROR_RETURN ((LM_ERROR, "%p send ack failed\n",
- "ttcp"), -1);
- }
- printf("Server finished. \n");
+ {
+ if (connection_stream.recv_n ((char *) message_buf, sizeof (long))
+ != sizeof (long))
+ ACE_ERROR_RETURN ((LM_ERROR,
+ "%p recv data control failed\n",
+ "ttcp"),
+ -1);
+
+ cnt = connection_stream.recv_n (& (message_buf->data_), message_buf->size_);
+ if (cnt != message_buf->size_)
+ ACE_ERROR_RETURN ((LM_ERROR, "recv data failed\n"), -1);
+
+ numCalls++;
+ nbytes += cnt;
+
+ if (connection_stream.send_n ((char *) &cnt, sizeof cnt)
+ != sizeof cnt)
+ ACE_ERROR_RETURN ((LM_ERROR,
+ "%p send ack failed\n",
+ "ttcp"),
+ -1);
+ }
+ printf("Server finished. \n");
}
/* if (errno)
@@ -522,10 +533,10 @@ main (int argc, char *argv[])
(void) read_timer (stats, sizeof (stats));
if (udp && trans)
{
- (void) Nwrite (connection_stream, message_buf, 4); /* rcvr end */
- (void) Nwrite (connection_stream, message_buf, 4); /* rcvr end */
- (void) Nwrite (connection_stream, message_buf, 4); /* rcvr end */
- (void) Nwrite (connection_stream, message_buf, 4); /* rcvr end */
+ (void) Nwrite (connection_stream, message_buf, 4); /* rcvr end */
+ (void) Nwrite (connection_stream, message_buf, 4); /* rcvr end */
+ (void) Nwrite (connection_stream, message_buf, 4); /* rcvr end */
+ (void) Nwrite (connection_stream, message_buf, 4); /* rcvr end */
}
if (cput <= 0.0)
cput = 0.001;
@@ -541,7 +552,7 @@ main (int argc, char *argv[])
ACE_OS::sprintf (filename, "%s.results", title);
fd = fopen(filename,"a+");
if (new_line)
- fprintf(fd,"\n -l %ldk \t", data_buf_len/1024);
+ fprintf(fd,"\n -l %ldk \t", data_buf_len/1024);
tmp = ((double) nbytes) / realt;
fprintf(fd,"%.2f ", tmp * 8.0 / 1024.0 / 1024.0);
fclose(fd);
@@ -549,29 +560,29 @@ main (int argc, char *argv[])
#endif
fprintf (stdout,
- "ttcp%s: %ld bytes in %.2f real seconds = %s/sec +++\n",
- trans ? "-t" : "-r",
- nbytes, realt, outfmt (((double) nbytes) / realt));
+ "ttcp%s: %ld bytes in %.2f real seconds = %s/sec +++\n",
+ trans ? "-t" : "-r",
+ nbytes, realt, outfmt (((double) nbytes) / realt));
if (verbose)
{
fprintf (stdout,
- "ttcp%s: %ld bytes in %.2f CPU seconds = %s/cpu sec\n",
- trans ? "-t" : "-r",
- nbytes, cput, outfmt (((double) nbytes) / cput));
+ "ttcp%s: %ld bytes in %.2f CPU seconds = %s/cpu sec\n",
+ trans ? "-t" : "-r",
+ nbytes, cput, outfmt (((double) nbytes) / cput));
}
fprintf (stdout,
- "ttcp%s: %d I/O calls, msec/call = %.2f, calls/sec = %.2f\n",
- trans ? "-t" : "-r",
- numCalls,
- 1024.0 * realt / ((double) numCalls),
- ((double) numCalls) / realt);
+ "ttcp%s: %d I/O calls, msec/call = %.2f, calls/sec = %.2f\n",
+ trans ? "-t" : "-r",
+ numCalls,
+ 1024.0 * realt / ((double) numCalls),
+ ((double) numCalls) / realt);
fprintf (stdout, "ttcp%s: %s\n", trans ? "-t" : "-r", stats);
if (verbose)
{
fprintf (stdout,
- "ttcp%s: buffer address %#x\n",
- trans ? "-t" : "-r",
- message_buf);
+ "ttcp%s: buffer address %#x\n",
+ trans ? "-t" : "-r",
+ message_buf);
}
exit (0);
@@ -603,7 +614,7 @@ pattern (register char *cp, register int cnt)
while (cnt-- > 0)
{
while (!isprint ((c & 0x7F)))
- c++;
+ c++;
*cp++ = (c++ & 0x7F);
}
}
@@ -637,8 +648,8 @@ outfmt (double b)
return obuf;
}
-static struct itimerval itime0; /* Time at which timing started */
-static struct rusage ru0; /* Resource utilization at the start */
+static struct itimerval itime0; /* Time at which timing started */
+static struct rusage ru0; /* Resource utilization at the start */
#if defined(SYSV)
/*ARGSUSED */
@@ -665,7 +676,7 @@ prep_timer ()
{
itime0.it_interval.tv_sec = 0;
itime0.it_interval.tv_usec = 0;
- // itime0.it_value.tv_sec = LONG_MAX / 22; /* greatest possible value , itimer() count backwards */
+ // itime0.it_value.tv_sec = LONG_MAX / 22; /* greatest possible value , itimer() count backwards */
itime0.it_value.tv_sec = 3600;
itime0.it_value.tv_usec = 0;
@@ -726,8 +737,8 @@ read_timer (char *str, int len)
}
static void
-prusage (register struct rusage *r0, struct rusage *r1,
- struct timeval *b, struct timeval *e, char *outp)
+prusage (register struct rusage *r0, struct rusage *r1,
+ struct timeval *b, struct timeval *e, char *outp)
{
struct timeval tdiff;
register time_t t;
@@ -736,16 +747,16 @@ prusage (register struct rusage *r0, struct rusage *r1,
int ms;
t = (r1->ru_utime.tv_sec - r0->ru_utime.tv_sec) * 1000 +
- (r1->ru_utime.tv_usec - r0->ru_utime.tv_usec) / 100000 +
- (r1->ru_stime.tv_sec - r0->ru_stime.tv_sec) * 1000 +
- (r1->ru_stime.tv_usec - r0->ru_stime.tv_usec) / 100000;
+ (r1->ru_utime.tv_usec - r0->ru_utime.tv_usec) / 100000 +
+ (r1->ru_stime.tv_sec - r0->ru_stime.tv_sec) * 1000 +
+ (r1->ru_stime.tv_usec - r0->ru_stime.tv_usec) / 100000;
ms = -((e->tv_sec - b->tv_sec) * 1000 + (e->tv_usec - b->tv_usec) / 1000);/* in milliseconds */
#define END(x) {while(*x) x++;}
#if defined(SYSV)
cp = "%Uuser %Ssys %Ereal %P";
#else
-#if defined(sgi) /* IRIX 3.3 will show 0 for %M,%F,%R,%C */
+#if defined(sgi) /* IRIX 3.3 will show 0 for %M,%F,%R,%C */
cp = "%Uuser %Ssys %Ereal %P %Mmaxrss %F+%Rpf %Ccsw";
#else
cp = "%Uutime %Sstime %Edtime %P cpu occupancy";
@@ -755,91 +766,91 @@ prusage (register struct rusage *r0, struct rusage *r1,
for (; *cp; cp++)
{
if (*cp != '%')
- *outp++ = *cp;
+ *outp++ = *cp;
else if (cp[1])
- switch (*++cp)
- {
-
- case 'U':
- tvsub (&tdiff, &r1->ru_utime, &r0->ru_utime);
- /* sprintf (outp, "%d.%01d", tdiff.tv_sec, tdiff.tv_usec);*/
+ switch (*++cp)
+ {
+ case 'U':
+ tvsub (&tdiff, &r1->ru_utime, &r0->ru_utime);
+ /* sprintf (outp, "%d.%01d", tdiff.tv_sec, tdiff.tv_usec);*/
sprintf (outp, "%f", (tdiff.tv_sec + tdiff.tv_usec/1000000.0));
- END (outp);
- break;
+ END (outp);
+ break;
+
+ case 'S':
+ tvsub (&tdiff, &r1->ru_stime, &r0->ru_stime);
+ /* sprintf (outp, "%d.%01d", tdiff.tv_sec, tdiff.tv_usec);*/
+ sprintf (outp, "%f", (tdiff.tv_sec + tdiff.tv_usec/1000000.0));
+ END (outp);
+ break;
+
+ case 'E':
+ psecs (ms / 1000, outp);
+ END (outp);
+ break;
+
+ case 'P':
+ sprintf (outp, "%f%%", (t * 100.0 / ((ms ? ms : 1))));
+ END (outp);
+ break;
+
+ #if !defined(SYSV)
+ case 'W':
+ i = r1->ru_nswap - r0->ru_nswap;
+ sprintf (outp, "%d", i);
+ END (outp);
+ break;
+
+ case 'X':
+ sprintf (outp, "%d", t == 0 ? 0 : (r1->ru_ixrss - r0->ru_ixrss) / t);
+ END (outp);
+ break;
+
+ case 'D':
+ sprintf (outp, "%d", t == 0 ? 0 :
+ (r1->ru_idrss + r1->ru_isrss - (r0->ru_idrss + r0->ru_isrss)) / t);
+ END (outp);
+ break;
- case 'S':
- tvsub (&tdiff, &r1->ru_stime, &r0->ru_stime);
- /* sprintf (outp, "%d.%01d", tdiff.tv_sec, tdiff.tv_usec);*/
- sprintf (outp, "%f", (tdiff.tv_sec + tdiff.tv_usec/1000000.0));
- END (outp);
- break;
-
- case 'E':
- psecs (ms / 1000, outp);
- END (outp);
- break;
-
- case 'P':
- sprintf (outp, "%f%%", (t * 100.0 / ((ms ? ms : 1))));
- END (outp);
- break;
-
-#if !defined(SYSV)
- case 'W':
- i = r1->ru_nswap - r0->ru_nswap;
- sprintf (outp, "%d", i);
- END (outp);
- break;
-
- case 'X':
- sprintf (outp, "%d", t == 0 ? 0 : (r1->ru_ixrss - r0->ru_ixrss) / t);
- END (outp);
- break;
-
- case 'D':
- sprintf (outp, "%d", t == 0 ? 0 :
- (r1->ru_idrss + r1->ru_isrss - (r0->ru_idrss + r0->ru_isrss)) / t);
- END (outp);
- break;
-
- case 'K':
- sprintf (outp, "%d", t == 0 ? 0 :
- ((r1->ru_ixrss + r1->ru_isrss + r1->ru_idrss) -
- (r0->ru_ixrss + r0->ru_idrss + r0->ru_isrss)) / t);
- END (outp);
- break;
-
- case 'M':
- sprintf (outp, "%d", r1->ru_maxrss / 2);
- END (outp);
- break;
-
- case 'F':
- sprintf (outp, "%d", r1->ru_majflt - r0->ru_majflt);
- END (outp);
- break;
-
- case 'R':
- sprintf (outp, "%d", r1->ru_minflt - r0->ru_minflt);
- END (outp);
- break;
-
- case 'I':
- sprintf (outp, "%d", r1->ru_inblock - r0->ru_inblock);
- END (outp);
- break;
-
- case 'O':
- sprintf (outp, "%d", r1->ru_oublock - r0->ru_oublock);
- END (outp);
- break;
- case 'C':
- sprintf (outp, "%d+%d", r1->ru_nvcsw - r0->ru_nvcsw,
- r1->ru_nivcsw - r0->ru_nivcsw);
- END (outp);
- break;
-#endif /* !SYSV */
- }
+ case 'K':
+ sprintf (outp, "%d", t == 0 ? 0 :
+ ((r1->ru_ixrss + r1->ru_isrss + r1->ru_idrss) -
+ (r0->ru_ixrss + r0->ru_idrss + r0->ru_isrss)) / t);
+ END (outp);
+ break;
+
+ case 'M':
+ sprintf (outp, "%d", r1->ru_maxrss / 2);
+ END (outp);
+ break;
+
+ case 'F':
+ sprintf (outp, "%d", r1->ru_majflt - r0->ru_majflt);
+ END (outp);
+ break;
+
+ case 'R':
+ sprintf (outp, "%d", r1->ru_minflt - r0->ru_minflt);
+ END (outp);
+ break;
+
+ case 'I':
+ sprintf (outp, "%d", r1->ru_inblock - r0->ru_inblock);
+ END (outp);
+ break;
+
+ case 'O':
+ sprintf (outp, "%d", r1->ru_oublock - r0->ru_oublock);
+ END (outp);
+ break;
+
+ case 'C':
+ sprintf (outp, "%d+%d", r1->ru_nvcsw - r0->ru_nvcsw,
+ r1->ru_nivcsw - r0->ru_nivcsw);
+ END (outp);
+ break;
+ #endif /* !SYSV */
+ }
}
*outp = '\0';
}
@@ -940,12 +951,12 @@ mread (int fd, register char *bufp, unsigned n)
nread = read (fd, bufp, n - count);
numCalls++;
if (nread < 0)
- {
- perror ("ttcp_mread");
- return (-1);
- }
+ {
+ perror ("ttcp_mread");
+ return (-1);
+ }
if (nread == 0)
- return ((int) count);
+ return ((int) count);
count += (unsigned) nread;
bufp += nread;
}
diff --git a/ACE/performance-tests/TTCP/C/new-ttcp.cpp b/ACE/performance-tests/TTCP/C/new-ttcp.cpp
index d355f0b6d56..eb7753f762e 100644
--- a/ACE/performance-tests/TTCP/C/new-ttcp.cpp
+++ b/ACE/performance-tests/TTCP/C/new-ttcp.cpp
@@ -14,13 +14,13 @@
* T.C. Slattery, USNA
* Minor improvements, Mike Muuss and Terry Slattery, 16-Oct-85.
* Modified in 1989 at Silicon Graphics, Inc.
- * catch SIGPIPE to be able to print stats when receiver has died
+ * catch SIGPIPE to be able to print stats when receiver has died
* for tcp, don't look for sentinel during reads to allow small transfers
* increased default buffer size to 8K, nbuf to 2K to transfer 16MB
* moved default port to 5001, beyond IPPORT_USERRESERVED
- * make sinkmode default because it is more popular,
- * -s now means don't sink/source
- * count number of read/write system calls to see effects of
+ * make sinkmode default because it is more popular,
+ * -s now means don't sink/source
+ * count number of read/write system calls to see effects of
* blocking from full socket buffers
* for tcp, -D option turns off buffered writes (sets TCP_NODELAY sockopt)
* buffer alignment options, -A and -O
@@ -68,7 +68,7 @@
#include <netinet/tcp.h>
#include <arpa/inet.h>
#include <netdb.h>
-#include <sys/time.h> /* struct itimerval */
+#include <sys/time.h> /* struct itimerval */
#include <limits.h>
#include <sys/un.h>
#include <unistd.h>
@@ -83,9 +83,9 @@ ACE_INET_Addr address;
#include <sys/times.h>
#include <sys/param.h>
struct rusage
- {
- struct timeval ru_utime, ru_stime;
- };
+{
+ struct timeval ru_utime, ru_stime;
+};
#define RUSAGE_SELF 0
#else
@@ -107,7 +107,7 @@ int connection_descriptor;
struct Session_Control_Message
{
- long nbuf_;
+ long nbuf_;
// number of buffers that will be sent this round.
long size_;
// size of the buffers that will be sent
@@ -121,33 +121,33 @@ struct Data_Control_Message
int fromlen;
int domain = PF_INET; /* Default is to use Internet domain sockets. */
-char *domainname; /* Rendezvous address for UNIX domain sockets. */
-int fd; /* fd of network socket */
-
-int data_buf_len = 1024 * 1024 * 2; // length of data portion
-long total_msg_len; // length of entire message
-char *data_buf; // pointer to data portion
-int nbuf = 2 * 1024; /* number of buffers to send in sinkmode */
-
-int bufoffset = 0; /* align buffer to this */
-int bufalign = 16 * 1024; /* modulo this */
-
-int udp = 0; /* 0 = tcp, !0 = udp */
-int options = 0; /* socket options */
-int one = 1; /* for 4.3 BSD style setsockopt() */
-short port = 5001; /* TCP port number */
-char *host; /* ptr to name of host */
-int trans; /* 0=receive, !0=transmit mode */
-int sinkmode = 0; /* 0=normal I/O, !0=sink/source mode */
-int verbose = 0; /* 0=print basic info, 1=print cpu rate, proc
- * resource usage. */
-int nodelay = 0; /* set TCP_NODELAY socket option */
-int b_flag = 0; /* use mread() */
-int sockbufsize = 0; /* socket buffer size to use */
-char fmt = 'K'; /* output format: k = kilobits, K = kilobytes,
- * m = megabits, M = megabytes,
- * g = gigabits, G = gigabytes */
-int touchdata = 0; /* access data after reading */
+char *domainname; /* Rendezvous address for UNIX domain sockets. */
+int fd; /* fd of network socket */
+
+int data_buf_len = 1024 * 1024 * 2; // length of data portion
+long total_msg_len; // length of entire message
+char *data_buf; // pointer to data portion
+int nbuf = 2 * 1024; /* number of buffers to send in sinkmode */
+
+int bufoffset = 0; /* align buffer to this */
+int bufalign = 16 * 1024; /* modulo this */
+
+int udp = 0; /* 0 = tcp, !0 = udp */
+int options = 0; /* socket options */
+int one = 1; /* for 4.3 BSD style setsockopt() */
+short port = 5001; /* TCP port number */
+char *host; /* ptr to name of host */
+int trans; /* 0=receive, !0=transmit mode */
+int sinkmode = 0; /* 0=normal I/O, !0=sink/source mode */
+int verbose = 0; /* 0=print basic info, 1=print cpu rate, proc
+ * resource usage. */
+int nodelay = 0; /* set TCP_NODELAY socket option */
+int b_flag = 0; /* use mread() */
+int sockbufsize = 0; /* socket buffer size to use */
+char fmt = 'K'; /* output format: k = kilobits, K = kilobytes,
+ * m = megabits, M = megabytes,
+ * g = gigabits, G = gigabytes */
+int touchdata = 0; /* access data after reading */
struct hostent *addr;
extern int errno;
@@ -155,33 +155,33 @@ extern int optind;
extern char *optarg;
char Usage[] = "\
-Usage: ttcp -t [-options] host [ < in ]\n\
- ttcp -r [-options > out]\n\
-Common options:\n\
- -l ## length of bufs read from or written to network (default 8192)\n\
- -u use UDP instead of TCP\n\
- -U use UNIX domain sockets instead of Internet domain sockets\n\
- -p ## port number to send to or listen at (default 5001)\n\
- -s -t: source a pattern to network\n\
- -r: sink (discard) all data from network\n\
- -A align the start of buffers to this modulus (default 16384)\n\
- -O start buffers at this offset from the modulus (default 0)\n\
- -v verbose: print more statistics\n\
- -d set SO_DEBUG socket option\n\
- -b ## set socket buffer size (if supported)\n\
- -f X format for rate: k,K = kilo{bit,byte}; m,M = mega; g,G = giga\n\
-Options specific to -t:\n\
- -n## number of source bufs written to network (default 2048)\n\
- -D don't buffer TCP writes (sets TCP_NODELAY socket option)\n\
-Options specific to -r:\n\
- -B for -s, only output full blocks as specified by -l (for TAR)\n\
- -T \"touch\": access each byte as it's read\n\
-";
+ Usage: ttcp -t [-options] host [ < in ]\n\
+ ttcp -r [-options > out]\n\
+ Common options:\n\
+ -l ## length of bufs read from or written to network (default 8192)\n\
+ -u use UDP instead of TCP\n\
+ -U use UNIX domain sockets instead of Internet domain sockets\n\
+ -p ## port number to send to or listen at (default 5001)\n\
+ -s -t: source a pattern to network\n\
+ -r: sink (discard) all data from network\n\
+ -A align the start of buffers to this modulus (default 16384)\n\
+ -O start buffers at this offset from the modulus (default 0)\n\
+ -v verbose: print more statistics\n\
+ -d set SO_DEBUG socket option\n\
+ -b ## set socket buffer size (if supported)\n\
+ -f X format for rate: k,K = kilo{bit,byte}; m,M = mega; g,G = giga\n\
+ Options specific to -t:\n\
+ -n## number of source bufs written to network (default 2048)\n\
+ -D don't buffer TCP writes (sets TCP_NODELAY socket option)\n\
+ Options specific to -r:\n\
+ -B for -s, only output full blocks as specified by -l (for TAR)\n\
+ -T \"touch\": access each byte as it's read\n\
+ ";
char stats[128];
-unsigned long nbytes; /* bytes on net */
-unsigned long numCalls = 0; /* # of I/O system calls */
-double cput, realt; /* user, real time (seconds) */
+unsigned long nbytes; /* bytes on net */
+unsigned long numCalls = 0; /* # of I/O system calls */
+double cput, realt; /* user, real time (seconds) */
void err (char *s);
void mes (char *s);
@@ -200,8 +200,8 @@ int Nread (ACE_SOCK_Stream &s, void *buf, int count);
int Nwrite (ACE_SOCK_Stream &s, void *buf, int count);
#if !defined (__cplusplus)
-typedef void (*SIG_TYP)();
-#endif
+typedef void (*SIG_TYP)();
+#endif
#ifdef SVR4
void
@@ -229,82 +229,82 @@ main (int argc, char *argv[])
while ((c = getopt (argc, argv, "drstU:uvBDTb:f:l:n:p:A:O:L:xh:")) != -1)
{
switch (c)
- {
-
- case 'h':
- host = optarg;
+ {
+ case 'h':
+ host = optarg;
+ break;
+ case 'x':
+ new_line = 1;
+ break;
+ case 'L':
+ title = optarg;
+ break;
+ case 'B':
+ b_flag = 1;
+ break;
+ case 't':
+ trans = 1;
+ break;
+ case 'r':
+ trans = 0;
+ break;
+ case 'd':
+ options |= SO_DEBUG;
+ break;
+ case 'D':
+ #ifdef TCP_NODELAY
+ nodelay = 1;
+ #else
+ fprintf (stderr,
+ "ttcp: -D option ignored: TCP_NODELAY socket option not supported\n");
+ #endif
+ break;
+ case 'n':
+ nbuf = atoi (optarg);
+ break;
+ case 'l':
+ data_buf_len = atoi (optarg);
+ break;
+ case 's':
+ sinkmode = !sinkmode;
+ break;
+ case 'p':
+ port = atoi (optarg);
break;
- case 'x':
- new_line = 1;
- break;
- case 'L':
- title = optarg;
- break;
- case 'B':
- b_flag = 1;
- break;
- case 't':
- trans = 1;
- break;
- case 'r':
- trans = 0;
- break;
- case 'd':
- options |= SO_DEBUG;
- break;
- case 'D':
-#ifdef TCP_NODELAY
- nodelay = 1;
-#else
- fprintf (stderr,
- "ttcp: -D option ignored: TCP_NODELAY socket option not supported\n");
-#endif
- break;
- case 'n':
- nbuf = atoi (optarg);
- break;
- case 'l':
- data_buf_len = atoi (optarg);
- break;
- case 's':
- sinkmode = !sinkmode;
- break;
- case 'p':
- port = atoi (optarg);
- break;
case 'U':
- domain = PF_UNIX;
- domainname = optarg;
- break;
- case 'u':
- udp = 1;
- break;
- case 'v':
- verbose = 1;
- break;
- case 'A':
- bufalign = atoi (optarg);
- break;
- case 'O':
- bufoffset = atoi (optarg);
- break;
- case 'b':
-#if defined(SO_SNDBUF) || defined(SO_RCVBUF)
- sockbufsize = atoi (optarg);
-#else
- fprintf (stderr, "ttcp: -b option ignored: SO_SNDBUF/SO_RCVBUF socket options not supported\n");
-#endif
- break;
- case 'f':
- fmt = *optarg;
- break;
- case 'T':
- touchdata = 1;
- break;
-
- default:
- goto usage;
- }
+ domain = PF_UNIX;
+ domainname = optarg;
+ break;
+ case 'u':
+ udp = 1;
+ break;
+ case 'v':
+ verbose = 1;
+ break;
+ case 'A':
+ bufalign = atoi (optarg);
+ break;
+ case 'O':
+ bufoffset = atoi (optarg);
+ break;
+ case 'b':
+ #if defined(SO_SNDBUF) || defined(SO_RCVBUF)
+ sockbufsize = atoi (optarg);
+ #else
+ fprintf (stderr,
+ "ttcp: -b option ignored: SO_SNDBUF/SO_RCVBUF socket options not supported\n");
+ #endif
+ break;
+ case 'f':
+ fmt = *optarg;
+ break;
+ case 'T':
+ touchdata = 1;
+ break;
+
+ default:
+ goto usage;
+ }
}
/* if transmitter, create remote address to transmit to. */
@@ -312,7 +312,7 @@ main (int argc, char *argv[])
if (trans)
{
if (address.set (port, host) == -1)
- perror ("address.set"), exit (1);
+ perror ("address.set"), exit (1);
}
/* else, receiver create address to listen on */
@@ -328,8 +328,8 @@ main (int argc, char *argv[])
if (message_buf == 0)
err ("malloc");
-// if (bufalign != 0)
-// message_buf += (bufalign - ((int) message_buf % bufalign) + bufoffset) % bufalign;
+ // if (bufalign != 0)
+ // message_buf += (bufalign - ((int) message_buf % bufalign) + bufoffset) % bufalign;
// let's go ahead and set the control message for every send right now
message_buf->size_ = data_buf_len;
@@ -344,27 +344,27 @@ main (int argc, char *argv[])
if (trans)
{
fprintf (stdout,
- "ttcp-t: data_buf_len=%d, nbuf=%d, align=%d/%d, port=%d",
- data_buf_len, nbuf, bufalign, bufoffset, port);
+ "ttcp-t: data_buf_len=%d, nbuf=%d, align=%d/%d, port=%d",
+ data_buf_len, nbuf, bufalign, bufoffset, port);
if (sockbufsize)
- fprintf (stdout, ", sockbufsize=%d", sockbufsize);
- fprintf (stdout, " %s -> %s\n",
- domain == PF_INET ? (udp ? "udp" : "tcp") : "unix",
- host == 0 ? domainname : host);
+ fprintf (stdout, ", sockbufsize=%d", sockbufsize);
+ fprintf (stdout, " %s -> %s\n",
+ domain == PF_INET ? (udp ? "udp" : "tcp") : "unix",
+ host == 0 ? domainname : host);
}
else // receiver
{
fprintf (stdout,
- "ttcp-r: data_buf_len=%d, nbuf=%d, align=%d/%d, port=%d",
- data_buf_len, nbuf, bufalign, bufoffset, port);
+ "ttcp-r: data_buf_len=%d, nbuf=%d, align=%d/%d, port=%d",
+ data_buf_len, nbuf, bufalign, bufoffset, port);
if (sockbufsize)
- fprintf (stdout, ", sockbufsize=%d", sockbufsize);
+ fprintf (stdout, ", sockbufsize=%d", sockbufsize);
fprintf (stdout, " %s\n", domain == PF_INET ? (udp ? "udp" : "tcp") : "unix");
}
mes ("socket");
- //
+ //
// connect and accept
//
@@ -374,61 +374,63 @@ main (int argc, char *argv[])
/* the transmitter will set options and connect to receiver */
if (trans)
- {
- if (connector_factory.connect (connection_stream, address) == -1)
- perror ("connection failed"), exit (1);
- fprintf (stdout,
- "ttcp-t: data_buf_len=%d, nbuf=%d, align=%d/%d, port=%d",
- data_buf_len, nbuf, bufalign, bufoffset, port);
-
- // turn off weird ack things
- if (nodelay)
- {
- struct protoent *p = getprotobyname ("tcp");
-
- if (p && connection_stream.set_option (p->p_proto,
- TCP_NODELAY,
- (char *)& one,
- sizeof (one)))
- err ("setsockopt: nodelay");
- mes ("nodelay");
- }
- if (sockbufsize)
- {
- if (connection_stream.set_option (SOL_SOCKET,
- SO_SNDBUF,
- (char *) &sockbufsize,
- sizeof sockbufsize) == -1)
- err ("acceptor_factory.set_option");
- mes ("sndbuf");
- }
- }
+ {
+ if (connector_factory.connect (connection_stream, address) == -1)
+ perror ("connection failed"), exit (1);
+ fprintf (stdout,
+ "ttcp-t: data_buf_len=%d, nbuf=%d, align=%d/%d, port=%d",
+ data_buf_len, nbuf, bufalign, bufoffset, port);
+
+ // turn off weird ack things
+ if (nodelay)
+ {
+ struct protoent *p = getprotobyname ("tcp");
+
+ if (p && connection_stream.set_option (p->p_proto,
+ TCP_NODELAY,
+ (char *)& one,
+ sizeof (one)))
+ err ("setsockopt: nodelay");
+ mes ("nodelay");
+ }
+ if (sockbufsize)
+ {
+ if (connection_stream.set_option (SOL_SOCKET,
+ SO_SNDBUF,
+ (char *) &sockbufsize,
+ sizeof sockbufsize) == -1)
+ err ("acceptor_factory.set_option");
+ mes ("sndbuf");
+ }
+ }
/* receiver will listen for connections from the transmitter */
else
- {
- if (acceptor_factory.open (address, 1) == -1)
- perror ("acceptor open"), exit (1);
-
- ACE_INET_Addr remote_address;
-
- if (acceptor_factory.accept (connection_stream,
- (ACE_Addr *) &remote_address) == -1)
- perror ("acceptor accept"), exit (1);
-
- // set the window size
- if (sockbufsize)
- {
- if (connection_stream.set_option (SOL_SOCKET,
- SO_RCVBUF,
- (char *) &sockbufsize,
- sizeof sockbufsize) == -1)
- err ("acceptor_factory.set_option");
- mes ("rcvbuf");
- }
-
- fprintf (stderr, "ttcp-r: accept from %s\n", remote_address.get_host_name());
- }
+ {
+ if (acceptor_factory.open (address, 1) == -1)
+ perror ("acceptor open"), exit (1);
+
+ ACE_INET_Addr remote_address;
+
+ if (acceptor_factory.accept (connection_stream,
+ (ACE_Addr *) &remote_address) == -1)
+ perror ("acceptor accept"), exit (1);
+
+ // set the window size
+ if (sockbufsize)
+ {
+ if (connection_stream.set_option (SOL_SOCKET,
+ SO_RCVBUF,
+ (char *) &sockbufsize,
+ sizeof sockbufsize) == -1)
+ err ("acceptor_factory.set_option");
+ mes ("rcvbuf");
+ }
+
+ fprintf (stderr,
+ "ttcp-r: accept from %s\n",
+ remote_address.get_host_name());
+ }
}
//
@@ -446,45 +448,54 @@ main (int argc, char *argv[])
prep_timer ();
ACE_DEBUG ((LM_DEBUG, "Sending session control message"
- " nbuf %d, size %d\n", session_control_buf.nbuf_,
- session_control_buf.size_));
+ " nbuf %d, size %d\n", session_control_buf.nbuf_,
+ session_control_buf.size_));
if (send_n ((char *) &session_control_buf,
- sizeof (Session_Control_Message))
- != sizeof (Session_Control_Message))
- ACE_ERROR_RETURN ((LM_ERROR, "%p send session control failed\n",
- "ttcp"), -1);
+ sizeof (Session_Control_Message))
+ != sizeof (Session_Control_Message))
+ ACE_ERROR_RETURN ((LM_ERROR,
+ "%p send session control failed\n",
+ "ttcp"),
+ -1);
long ack;
int send_result;
while (nbuf--)
- {
- send_result = send_n ((char *) message_buf, total_msg_len);
- if (send_result != total_msg_len)
- ACE_ERROR_RETURN ((LM_ERROR, "%p only sent %d of %d bytes on call %d\n",
- "ttcp", send_result, total_msg_len, numCalls + 1), -1);
- numCalls++;
- nbytes += data_buf_len;
-
- if (recv_n ((char *) &ack, sizeof ack) != sizeof ack)
- ACE_ERROR_RETURN ((LM_ERROR, "%p recv of ack failed\n",
- "ttcp"), -1);
-
- if (ack != data_buf_len)
- ACE_DEBUG ((LM_DEBUG, "received ack for only %d bytes\n", ack));
- }
+ {
+ send_result = send_n ((char *) message_buf, total_msg_len);
+ if (send_result != total_msg_len)
+ ACE_ERROR_RETURN ((LM_ERROR,
+ "%p only sent %d of %d bytes on call %d\n",
+ "ttcp", send_result, total_msg_len, numCalls + 1),
+ -1);
+ numCalls++;
+ nbytes += data_buf_len;
+
+ if (recv_n ((char *) &ack, sizeof ack) != sizeof ack)
+ ACE_ERROR_RETURN ((LM_ERROR,
+ "%p recv of ack failed\n",
+ "ttcp"),
+ -1);
+
+ if (ack != data_buf_len)
+ ACE_DEBUG ((LM_DEBUG, "received ack for only %d bytes\n", ack));
+ }
}
else
{
prep_timer ();
if (recv_n ((char *) &session_control_buf,
- sizeof (Session_Control_Message)) != sizeof (Session_Control_Message))
- ACE_ERROR_RETURN ((LM_ERROR, "%p recv session control failed\n",
- "ttcp"), -1);
+ sizeof (Session_Control_Message))
+ != sizeof (Session_Control_Message))
+ ACE_ERROR_RETURN ((LM_ERROR,
+ "%p recv session control failed\n",
+ "ttcp"),
+ -1);
ACE_DEBUG ((LM_DEBUG, "received session control message"
- " nbuf %d, size %d\n", session_control_buf.nbuf_,
- session_control_buf.size_));
+ " nbuf %d, size %d\n", session_control_buf.nbuf_,
+ session_control_buf.size_));
nbuf = session_control_buf.nbuf_;
// ignore session_control_buf.size_ for now
@@ -492,22 +503,26 @@ main (int argc, char *argv[])
long cnt;
while (nbuf--)
- {
- if (recv_n ((char *) message_buf, sizeof (long)) != sizeof (long))
- ACE_ERROR_RETURN ((LM_ERROR, "%p recv data control failed\n",
- "ttcp"), -1);
-
- cnt = recv_n (& (message_buf->data_), message_buf->size_);
- if (cnt != message_buf->size_)
- ACE_ERROR_RETURN ((LM_ERROR, "recv data failed\n"), -1);
-
- numCalls++;
- nbytes += cnt;
-
- if (send_n ((char *) &cnt, sizeof cnt) != sizeof cnt)
- ACE_ERROR_RETURN ((LM_ERROR, "%p send ack failed\n",
- "ttcp"), -1);
- }
+ {
+ if (recv_n ((char *) message_buf, sizeof (long)) != sizeof (long))
+ ACE_ERROR_RETURN ((LM_ERROR,
+ "%p recv data control failed\n",
+ "ttcp"),
+ -1);
+
+ cnt = recv_n (& (message_buf->data_), message_buf->size_);
+ if (cnt != message_buf->size_)
+ ACE_ERROR_RETURN ((LM_ERROR, "recv data failed\n"), -1);
+
+ numCalls++;
+ nbytes += cnt;
+
+ if (send_n ((char *) &cnt, sizeof cnt) != sizeof cnt)
+ ACE_ERROR_RETURN ((LM_ERROR,
+ "%p send ack failed\n",
+ "ttcp"),
+ -1);
+ }
}
if (errno)
@@ -520,10 +535,10 @@ main (int argc, char *argv[])
(void) read_timer (stats, sizeof (stats));
if (udp && trans)
{
- (void) Nwrite (connection_stream, message_buf, 4); /* rcvr end */
- (void) Nwrite (connection_stream, message_buf, 4); /* rcvr end */
- (void) Nwrite (connection_stream, message_buf, 4); /* rcvr end */
- (void) Nwrite (connection_stream, message_buf, 4); /* rcvr end */
+ (void) Nwrite (connection_stream, message_buf, 4); /* rcvr end */
+ (void) Nwrite (connection_stream, message_buf, 4); /* rcvr end */
+ (void) Nwrite (connection_stream, message_buf, 4); /* rcvr end */
+ (void) Nwrite (connection_stream, message_buf, 4); /* rcvr end */
}
if (cput <= 0.0)
cput = 0.001;
@@ -537,39 +552,39 @@ main (int argc, char *argv[])
FILE *fd;
char filename[BUFSIZ];
ACE_OS::sprintf (filename, "%s.results", title);
- fd = fopen(filename,"a+");
+ fd = fopen(filename, "a+");
if (new_line)
- fprintf(fd,"\n -l %ldk \t", data_buf_len/1024);
+ fprintf(fd, "\n -l %ldk \t", data_buf_len/1024);
tmp = ((double) nbytes) / realt;
- fprintf(fd,"%.2f ", tmp * 8.0 / 1024.0 / 1024.0);
+ fprintf(fd, "%.2f ", tmp * 8.0 / 1024.0 / 1024.0);
fclose(fd);
}
#endif
fprintf (stdout,
- "ttcp%s: %ld bytes in %.2f real seconds = %s/sec +++\n",
- trans ? "-t" : "-r",
- nbytes, realt, outfmt (((double) nbytes) / realt));
+ "ttcp%s: %ld bytes in %.2f real seconds = %s/sec +++\n",
+ trans ? "-t" : "-r",
+ nbytes, realt, outfmt (((double) nbytes) / realt));
if (verbose)
{
fprintf (stdout,
- "ttcp%s: %ld bytes in %.2f CPU seconds = %s/cpu sec\n",
- trans ? "-t" : "-r",
- nbytes, cput, outfmt (((double) nbytes) / cput));
+ "ttcp%s: %ld bytes in %.2f CPU seconds = %s/cpu sec\n",
+ trans ? "-t" : "-r",
+ nbytes, cput, outfmt (((double) nbytes) / cput));
}
fprintf (stdout,
- "ttcp%s: %d I/O calls, msec/call = %.2f, calls/sec = %.2f\n",
- trans ? "-t" : "-r",
- numCalls,
- 1024.0 * realt / ((double) numCalls),
- ((double) numCalls) / realt);
+ "ttcp%s: %d I/O calls, msec/call = %.2f, calls/sec = %.2f\n",
+ trans ? "-t" : "-r",
+ numCalls,
+ 1024.0 * realt / ((double) numCalls),
+ ((double) numCalls) / realt);
fprintf (stdout, "ttcp%s: %s\n", trans ? "-t" : "-r", stats);
if (verbose)
{
fprintf (stdout,
- "ttcp%s: buffer address %#x\n",
- trans ? "-t" : "-r",
- message_buf);
+ "ttcp%s: buffer address %#x\n",
+ trans ? "-t" : "-r",
+ message_buf);
}
exit (0);
@@ -578,15 +593,15 @@ usage:
return 1;
}
-int
+int
send_n (const void *buf, int len)
{
size_t bytes_written;
- int n;
+ int n;
for (bytes_written = 0; bytes_written < len; bytes_written += n)
- if ((n = write (connection_descriptor, (const char *) buf + bytes_written,
- len - bytes_written)) == -1)
+ if ((n = write (connection_descriptor, (const char *) buf + bytes_written,
+ len - bytes_written)) == -1)
return -1;
return bytes_written;
@@ -596,16 +611,16 @@ int
recv_n (void *buf, int len)
{
size_t bytes_read;
- int n;
+ int n;
for (bytes_read = 0; bytes_read < len; bytes_read += n)
- if ((n = read (connection_descriptor, (char *) buf + bytes_read,
- len - bytes_read)) == -1)
+ if ((n = read (connection_descriptor, (char *) buf + bytes_read,
+ len - bytes_read)) == -1)
return -1;
else if (n == 0)
break;
- return bytes_read;
+ return bytes_read;
}
void
@@ -629,11 +644,11 @@ pattern (register char *cp, register int cnt)
register char c;
c = 0;
while (cnt-- > 0)
- {
- while (!isprint ((c & 0x7F)))
- c++;
- *cp++ = (c++ & 0x7F);
- }
+ {
+ while (!isprint ((c & 0x7F)))
+ c++;
+ *cp++ = (c++ & 0x7F);
+ }
}
char *
@@ -665,8 +680,8 @@ outfmt (double b)
return obuf;
}
-static struct itimerval itime0; /* Time at which timing started */
-static struct rusage ru0; /* Resource utilization at the start */
+static struct itimerval itime0; /* Time at which timing started */
+static struct rusage ru0; /* Resource utilization at the start */
#if defined(SYSV)
/*ARGSUSED */
@@ -693,7 +708,7 @@ prep_timer ()
{
itime0.it_interval.tv_sec = 0;
itime0.it_interval.tv_usec = 0;
- itime0.it_value.tv_sec = LONG_MAX / 22; /* greatest possible value , itimer() count backwards */
+ itime0.it_value.tv_sec = LONG_MAX / 22; /* greatest possible value , itimer() count backwards */
itime0.it_value.tv_usec = 0;
@@ -710,7 +725,7 @@ prep_timer ()
/*
* R E A D _ T I M E R
- *
+ *
*/
double
read_timer (char *str, int len)
@@ -747,8 +762,8 @@ read_timer (char *str, int len)
}
static void
-prusage (register struct rusage *r0, struct rusage *r1,
- struct timeval *e, struct timeval *b, char *outp)
+prusage (register struct rusage *r0, struct rusage *r1,
+ struct timeval *e, struct timeval *b, char *outp)
{
struct timeval tdiff;
register time_t t;
@@ -757,16 +772,16 @@ prusage (register struct rusage *r0, struct rusage *r1,
int ms;
t = (r1->ru_utime.tv_sec - r0->ru_utime.tv_sec) * 100 +
- (r1->ru_utime.tv_usec - r0->ru_utime.tv_usec) / 10000 +
- (r1->ru_stime.tv_sec - r0->ru_stime.tv_sec) * 100 +
- (r1->ru_stime.tv_usec - r0->ru_stime.tv_usec) / 10000;
+ (r1->ru_utime.tv_usec - r0->ru_utime.tv_usec) / 10000 +
+ (r1->ru_stime.tv_sec - r0->ru_stime.tv_sec) * 100 +
+ (r1->ru_stime.tv_usec - r0->ru_stime.tv_usec) / 10000;
ms = (e->tv_sec - b->tv_sec) * 100 + (e->tv_usec - b->tv_usec) / 10000;
#define END(x) {while(*x) x++;}
#if defined(SYSV)
cp = "%Uuser %Ssys %Ereal %P";
#else
-#if defined(sgi) /* IRIX 3.3 will show 0 for %M,%F,%R,%C */
+#if defined(sgi) /* IRIX 3.3 will show 0 for %M,%F,%R,%C */
cp = "%Uuser %Ssys %Ereal %P %Mmaxrss %F+%Rpf %Ccsw";
#else
cp = "%Uuser %Ssys %Ereal %P %Xi+%Dd %Mmaxrss %F+%Rpf %Ccsw";
@@ -775,89 +790,88 @@ prusage (register struct rusage *r0, struct rusage *r1,
for (; *cp; cp++)
{
if (*cp != '%')
- *outp++ = *cp;
+ *outp++ = *cp;
else if (cp[1])
- switch (*++cp)
- {
-
- case 'U':
- tvsub (&tdiff, &r1->ru_utime, &r0->ru_utime);
- sprintf (outp, "%d.%01d", tdiff.tv_sec, tdiff.tv_usec / 100000);
- END (outp);
- break;
-
- case 'S':
- tvsub (&tdiff, &r1->ru_stime, &r0->ru_stime);
- sprintf (outp, "%d.%01d", tdiff.tv_sec, tdiff.tv_usec / 100000);
- END (outp);
- break;
-
- case 'E':
- psecs (ms / 100, outp);
- END (outp);
- break;
-
- case 'P':
- sprintf (outp, "%d%%", (int) (t * 100 / ((ms ? ms : 1))));
- END (outp);
- break;
-
-#if !defined(SYSV)
- case 'W':
- i = r1->ru_nswap - r0->ru_nswap;
- sprintf (outp, "%d", i);
- END (outp);
- break;
-
- case 'X':
- sprintf (outp, "%d", t == 0 ? 0 : (r1->ru_ixrss - r0->ru_ixrss) / t);
- END (outp);
- break;
-
- case 'D':
- sprintf (outp, "%d", t == 0 ? 0 :
- (r1->ru_idrss + r1->ru_isrss - (r0->ru_idrss + r0->ru_isrss)) / t);
- END (outp);
- break;
-
- case 'K':
- sprintf (outp, "%d", t == 0 ? 0 :
- ((r1->ru_ixrss + r1->ru_isrss + r1->ru_idrss) -
- (r0->ru_ixrss + r0->ru_idrss + r0->ru_isrss)) / t);
- END (outp);
- break;
-
- case 'M':
- sprintf (outp, "%d", r1->ru_maxrss / 2);
- END (outp);
- break;
-
- case 'F':
- sprintf (outp, "%d", r1->ru_majflt - r0->ru_majflt);
- END (outp);
- break;
-
- case 'R':
- sprintf (outp, "%d", r1->ru_minflt - r0->ru_minflt);
- END (outp);
- break;
-
- case 'I':
- sprintf (outp, "%d", r1->ru_inblock - r0->ru_inblock);
- END (outp);
- break;
-
- case 'O':
- sprintf (outp, "%d", r1->ru_oublock - r0->ru_oublock);
- END (outp);
- break;
- case 'C':
- sprintf (outp, "%d+%d", r1->ru_nvcsw - r0->ru_nvcsw,
- r1->ru_nivcsw - r0->ru_nivcsw);
- END (outp);
- break;
-#endif /* !SYSV */
- }
+ switch (*++cp)
+ {
+ case 'U':
+ tvsub (&tdiff, &r1->ru_utime, &r0->ru_utime);
+ sprintf (outp, "%d.%01d", tdiff.tv_sec, tdiff.tv_usec / 100000);
+ END (outp);
+ break;
+
+ case 'S':
+ tvsub (&tdiff, &r1->ru_stime, &r0->ru_stime);
+ sprintf (outp, "%d.%01d", tdiff.tv_sec, tdiff.tv_usec / 100000);
+ END (outp);
+ break;
+
+ case 'E':
+ psecs (ms / 100, outp);
+ END (outp);
+ break;
+
+ case 'P':
+ sprintf (outp, "%d%%", (int) (t * 100 / ((ms ? ms : 1))));
+ END (outp);
+ break;
+
+ #if !defined(SYSV)
+ case 'W':
+ i = r1->ru_nswap - r0->ru_nswap;
+ sprintf (outp, "%d", i);
+ END (outp);
+ break;
+
+ case 'X':
+ sprintf (outp, "%d", t == 0 ? 0 : (r1->ru_ixrss - r0->ru_ixrss) / t);
+ END (outp);
+ break;
+
+ case 'D':
+ sprintf (outp, "%d", t == 0 ? 0 :
+ (r1->ru_idrss + r1->ru_isrss - (r0->ru_idrss + r0->ru_isrss)) / t);
+ END (outp);
+ break;
+
+ case 'K':
+ sprintf (outp, "%d", t == 0 ? 0 :
+ ((r1->ru_ixrss + r1->ru_isrss + r1->ru_idrss) -
+ (r0->ru_ixrss + r0->ru_idrss + r0->ru_isrss)) / t);
+ END (outp);
+ break;
+
+ case 'M':
+ sprintf (outp, "%d", r1->ru_maxrss / 2);
+ END (outp);
+ break;
+
+ case 'F':
+ sprintf (outp, "%d", r1->ru_majflt - r0->ru_majflt);
+ END (outp);
+ break;
+
+ case 'R':
+ sprintf (outp, "%d", r1->ru_minflt - r0->ru_minflt);
+ END (outp);
+ break;
+
+ case 'I':
+ sprintf (outp, "%d", r1->ru_inblock - r0->ru_inblock);
+ END (outp);
+ break;
+
+ case 'O':
+ sprintf (outp, "%d", r1->ru_oublock - r0->ru_oublock);
+ END (outp);
+ break;
+ case 'C':
+ sprintf (outp, "%d+%d", r1->ru_nvcsw - r0->ru_nvcsw,
+ r1->ru_nivcsw - r0->ru_nivcsw);
+ END (outp);
+ break;
+ #endif /* !SYSV */
+ }
}
*outp = '\0';
}
@@ -957,12 +971,12 @@ mread (int fd, register char *bufp, unsigned n)
nread = read (fd, bufp, n - count);
numCalls++;
if (nread < 0)
- {
- perror ("ttcp_mread");
- return (-1);
- }
+ {
+ perror ("ttcp_mread");
+ return (-1);
+ }
if (nread == 0)
- return ((int) count);
+ return ((int) count);
count += (unsigned) nread;
bufp += nread;
}