diff options
author | sergio <sergio@ae88bc3d-4319-0410-8dbf-d08b4c9d3795> | 1997-12-19 10:01:51 +0000 |
---|---|---|
committer | sergio <sergio@ae88bc3d-4319-0410-8dbf-d08b4c9d3795> | 1997-12-19 10:01:51 +0000 |
commit | 824930704db815ef7957f76da42551cd20be9717 (patch) | |
tree | 86cc22cfd24915f1bbe5c9b30332de984a497d8f | |
parent | 9ef856ae098961e90241fba7dfeda2902bb62902 (diff) | |
download | ATCD-824930704db815ef7957f76da42551cd20be9717.tar.gz |
*** empty log message ***
-rw-r--r-- | TAO/tests/Thruput/CORBAplus/Makefile | 69 | ||||
-rw-r--r-- | TAO/tests/Thruput/CORBAplus/README | 45 | ||||
-rw-r--r-- | TAO/tests/Thruput/CORBAplus/client.cpp | 301 | ||||
-rw-r--r-- | TAO/tests/Thruput/CORBAplus/extract | 4 | ||||
-rw-r--r-- | TAO/tests/Thruput/CORBAplus/run | 1 | ||||
-rw-r--r-- | TAO/tests/Thruput/CORBAplus/run_client | 25 | ||||
-rw-r--r-- | TAO/tests/Thruput/CORBAplus/run_server | 10 | ||||
-rw-r--r-- | TAO/tests/Thruput/CORBAplus/run_test | 34 | ||||
-rw-r--r-- | TAO/tests/Thruput/CORBAplus/run_tests | 36 | ||||
-rw-r--r-- | TAO/tests/Thruput/CORBAplus/server.cpp | 176 | ||||
-rw-r--r-- | TAO/tests/Thruput/CORBAplus/ttcp.idl | 34 | ||||
-rw-r--r-- | TAO/tests/Thruput/CORBAplus/ttcp_decl.h | 76 | ||||
-rw-r--r-- | TAO/tests/Thruput/CORBAplus/ttcp_i.cpp | 103 | ||||
-rw-r--r-- | TAO/tests/Thruput/CORBAplus/ttcp_i.h | 59 | ||||
-rw-r--r-- | TAO/tests/Thruput/CORBAplus/utils.cpp | 465 |
15 files changed, 1438 insertions, 0 deletions
diff --git a/TAO/tests/Thruput/CORBAplus/Makefile b/TAO/tests/Thruput/CORBAplus/Makefile new file mode 100644 index 00000000000..3f484ea7327 --- /dev/null +++ b/TAO/tests/Thruput/CORBAplus/Makefile @@ -0,0 +1,69 @@ +#---------------------------------------------------------------------------- +# $Id$ +# +# Top-level Makefile for the Thruput benchmark +#---------------------------------------------------------------------------- + +#---------------------------------------------------------------------------- +# Local macros +#---------------------------------------------------------------------------- + +LDLIBS = -lcorba -lunixsvc -lpbroker -lboadc -lnaming -llifecycl -lfsstream + +IDL_SRC = ttcp.cpp ttcp_s.cpp +PROG_SRCS = $(IDL_SRC) client.cpp ttcp_i.cpp server.cpp utils.cpp + +LSRC = $(PROG_SRCS) + +TTCP_CLIENT_OBJS = ttcp.o client.o utils.o + +TTCP_SERVER_OBJS = ttcp.o ttcp_s.o server.o ttcp_i.o utils.o + +BIN = client server + +BUILD = $(BIN) + +VLDLIBS = $(LDLIBS:%=%$(VAR)) +VBIN = $(BIN:%=%$(VAR)) + +#---------------------------------------------------------------------------- +# Include macros and targets +#---------------------------------------------------------------------------- + +exceptions = 1 + +include $(ACE_ROOT)/include/makeinclude/wrapper_macros.GNU +include $(ACE_ROOT)/include/makeinclude/macros.GNU +include $(ACE_ROOT)/include/makeinclude/rules.common.GNU +include $(ACE_ROOT)/include/makeinclude/rules.nonested.GNU +include $(ACE_ROOT)/include/makeinclude/rules.lib.GNU +#include $(ACE_ROOT)/include/makeinclude/rules.bin.GNU +include $(ACE_ROOT)/include/makeinclude/rules.local.GNU + +#---------------------------------------------------------------------------- +# Local modifications to variables imported by includes above. +#---------------------------------------------------------------------------- + +DCFLAGS = -g +LDFLAGS += -L$(PBHOME)/lib +CPPFLAGS += -I$(PBHOME)/include + +$(IDL_SRC): ttcp.idl + $(PBHOME)/bin/idlc ttcp.idl + -/bin/mv ttcp.C ttcp.cpp + -/bin/mv ttcp_s.C ttcp_s.cpp + +server: $(addprefix $(VDIR),$(TTCP_SERVER_OBJS)) + $(LINK.cc) $(LDFLAGS) -o $@ $^ $(PBHOME)/lib/iiop_s.o $(VLDLIBS) +#patch on the previous line to allow reading from an environment variable +#the host (interface) I would like the server to bind to. +#The patch is "$(PBHOME)/lib/iiop_s.o" + +client: $(addprefix $(VDIR),$(TTCP_CLIENT_OBJS)) + $(LINK.cc) $(LDFLAGS) -o $@ $^ $(VLDLIBS) + +clean: + -/bin/rm -rf *.o Log $(BIN) obj.* core Templates.DB .make.state + +realclean: clean + -/bin/rm -rf ttcp.cpp ttcp.h ttcp_s.cpp ttcp_s.h diff --git a/TAO/tests/Thruput/CORBAplus/README b/TAO/tests/Thruput/CORBAplus/README new file mode 100644 index 00000000000..e667b7ccc2d --- /dev/null +++ b/TAO/tests/Thruput/CORBAplus/README @@ -0,0 +1,45 @@ + CORBAplus TTCP Benchmark README file + +This directory contains a modified version of the TTCP benchmark that +uses the TAO ORB. TTCP is used to measure the throughput of CORBAplus +for sending different data types. This code tests sequences of short, +long, octet, char, double, and richly-typed data such as a struct. + +Organization +------------ + +client.cpp Client main program +server.cpp Server main program +ttcp.cpp Client side stubs +ttcp_s.cpp Server side skeletons +ttcp.h Header file for stubs +ttcp_s.h Header file for the skeletons +ttcp_i.cpp Implementaion of the interface +ttcp_i.h Header for the implementation +utils.cpp Utilities to calculate throughput +ttcp_decls.h Common declarations + +Results +------- +//Throughput results are stored under the results directory. If testing +//for REMOTE transfers, use the ./results/REMOTE directory. + +Running the tests +----------------- +Three scripts are provided + +(1) run_server : runs the server. Be sure to change the host name +(2) run_client : runs tests for various data types +(3) run_test : called by run_client + +Compiling +--------- + +Type make + +To provide for 2way tests (no data is sent in the reverse +direction. Sender blocks for a minimal ACK), comment out the -DONEWAY +flag from the CPPFLAGS + +-Aniruddha Gokhale +(gokhale@cs.wustl.edu) diff --git a/TAO/tests/Thruput/CORBAplus/client.cpp b/TAO/tests/Thruput/CORBAplus/client.cpp new file mode 100644 index 00000000000..82b50008bd6 --- /dev/null +++ b/TAO/tests/Thruput/CORBAplus/client.cpp @@ -0,0 +1,301 @@ +// ============================================================================ +// +// = TAO tests +// Throughput measurement using the TTCP benchmark adapted to work using TAO +// +// = FILENAME +// client.cpp +// +// Main program for the client +// +// = AUTHOR +// Aniruddha Gokhale +// +// ============================================================================ + +#include <iostream.h> +#include <fstream.h> + +#include "pbroker/corba/orb.h" +#include "pbroker/corba/request.h" +#include "pbroker/corba/environ.h" +#include "ace/ACE.h" +#include "ace/Get_Opt.h" +#include "ttcp.h" +#include "ttcp_decl.h" + +int print_usage (void); + +char Usage[] = + "Usage: client [-options] \n" + "Common options:\n" + "-l ## length of bufs read from or written to network (default 8192)\n" + "-v verbose: print more statistics\n" + "-d ## debug level\n" + "-f X format for rate: k,K = kilo{bit,byte}; m,M = mega; g,G = giga\n" + "-h ## Remote host to send data to\n" + "-p ## Port number" + "-L ## Output file name to store results\n" + "-S ## Total Data Size to be sent\n" + "-q <type> Send Sequence: Enumeration for various data types:\n" + "s = short, l = long, d = double, c = char\n" + "o = octet, S = BinStruct \n"; + +u_int _debug_level = 0; + +CORBA::Long trans = 1; // we are a client - used for debugging purposes +CORBA::Long buflen = 8 * 1024; // length of buffer, default 8,192 bytes +char *buf; // ptr to dynamic buffer +CORBA::Long nbuf; // number of buffers to send in sinkmode +CORBA::Short port = ACE_DEFAULT_SERVER_PORT; // TCP port number +char *host = "localhost"; // ptr to name of host +CORBA::Long verbose = 0; // 0=print basic info, 1=print cpu + // rate, proc resource usage. +CORBA::Char fmt = 'K'; // output + // format:k=kilobits,K=kilobytes, m = megabits, + // M = megabytes, g = gigabits, G = gigabytes +char *title = 0; // title of file to gather statistics +char stats[128]; // gathering the statistics +unsigned long srcDataSize; // Total amount of source data +unsigned long nbytes; // bytes on net +unsigned long numCalls; // # of I/O system calls +double cput, realt; // user, real time (seconds) +unsigned long dt; // data type + +// declare variables for various message types +ttcp_sequence::ShortSeq *sseq; +ttcp_sequence::LongSeq *lseq; +ttcp_sequence::OctetSeq *oseq; +ttcp_sequence::DoubleSeq *dseq; +ttcp_sequence::CharSeq *cseq; +ttcp_sequence::StructSeq *Sseq; + +int +main (int argc, char *argv[]) +{ + try { + int c; + CORBA::ORB_ptr orb_ptr; // underlying ORB + CORBA::String objkey = "TTCP_IIOP_test"; // name of the TTCP object on the + // server + CORBA::Object_ptr objref = CORBA::Object::_nil(); // object reference + ttcp_sequence_ptr ttcp_seq = 0; // obj reference to TTCP object + CORBA::Environment env; // environment + CORBA::String str; // holds the IOR + + fstream iorfile; + + ACE_UNUSED_ARG (objkey); + + // parse the arguments + ACE_Get_Opt get_opt (argc, argv, "d:vh:f:l:L:S:q:"); // Command line options + _debug_level = 0; + while ((c = get_opt ()) != -1) + { + switch (c) + { + case 'h': + host = ACE_OS::strdup (get_opt.optarg); + break; + case 'L': + title = ACE_OS::strdup (get_opt.optarg); + break; + case 'd': + _debug_level = ACE_OS::atoi (get_opt.optarg); + if (_debug_level > 10) + _debug_level = 10; + break; + case 'l': + buflen = ACE_OS::atoi (get_opt.optarg); + break; + case 'v': + verbose = 1; + break; + case 'f': + fmt = *get_opt.optarg; + break; + case 'S': /* total source data to send. */ + srcDataSize = ACE_OS::atoi (get_opt.optarg); + break; + case 'q': /* Send sequence of desired data type */ + switch(*get_opt.optarg){ + case 's': + dt = SEND_SHORT; + break; + case 'l': + dt = SEND_LONG; + break; + case 'd': + dt = SEND_DOUBLE; + break; + case 'c': + dt = SEND_CHAR; + break; + case 'o': + dt = SEND_OCTET; + break; + case 'S': + dt = SEND_STRUCT; + break; + case 'C': + dt = SEND_COMPOSITE; + break; + } + break; + // default: + //return print_usage (); + } + } + + // + // Transmitter + // + + // get a handle to the ORB + orb_ptr = CORBA::ORB_init (argc, + argv); + if (env.exception () != 0) + { + // env.print_exception ("ORB initialization", stdout); + return -1; + } + + // Retrieve a factory objref. + objref = orb_ptr->resolve_initial_references ("TTCP_IIOP_test"); + // @@ put exception handling here !! + + if (CORBA::is_nil (objref) == CORBA_TRUE) + ACE_ERROR_RETURN ((LM_ERROR, + "resolve_initial_references returned null object for ttcp_sequence\n"), + -1); + + + if (!CORBA::is_nil (objref)) + { + // if it is a valid obj ref, narrow it to a ttcp_sequence CORBA object + ttcp_seq = ttcp_sequence::_narrow (objref); + + if (!CORBA::is_nil (ttcp_seq)) + { + + // the number of iterations is based on the total data size and the + // individual buffer size sent + nbuf = srcDataSize/buflen; + ACE_DEBUG ((LM_DEBUG, "data size = %d, buflen = %d, nbuf = %d\n", + srcDataSize, buflen, nbuf)); + + // + // Prepare the Message to be sent + // + + // first allocate a buffer of the desired size and alignment + errno = 0; + if ((buf = (char *) ACE_OS::malloc (buflen)) == (char *) NULL) + err ("malloc"); + + // fill the buffer with the data type to be sent + FillPattern (buf, buflen, dt); + + // + // Start the timers on the client and server sides + // + prep_timer (); // start our time + ttcp_seq->start_timer (); // ask the server to start its timer + if (env.exception () != 0) + { + // env.print_exception ("start_timer operation", stdout); + return -1; + } + +#if defined (USE_QUANTIFY) + /* start recording quantify data from here */ + quantify_clear_data (); + quantify_start_recording_data (); +#endif + // send the same buffer nbuf times + while (nbuf--) + { + switch (dt){ + case SEND_SHORT: + ttcp_seq->sendShortSeq (*sseq); + nbytes += sseq->length () * sizeof (CORBA::Short); + break; + case SEND_LONG: + ttcp_seq->sendLongSeq (*lseq); + nbytes += lseq->length () * sizeof (CORBA::Long); + break; + case SEND_OCTET: + ttcp_seq->sendOctetSeq (*oseq); + nbytes += oseq->length () * sizeof (CORBA::Octet); + break; + case SEND_DOUBLE: + ttcp_seq->sendDoubleSeq (*dseq); + nbytes += dseq->length () * sizeof (CORBA::Double); + break; + case SEND_CHAR: + ttcp_seq->sendCharSeq (*cseq); + nbytes += cseq->length () * sizeof (CORBA::Char); + break; + case SEND_STRUCT: + ttcp_seq->sendStructSeq (*Sseq); + nbytes += Sseq->length () * sizeof (BinStruct); + break; + } + + numCalls++; // nbytes and numCalls are used in the thruput + // measurement + } +#if defined (USE_QUANTIFY) + quantify_stop_recording_data(); +#endif + // + // Stop the timer + // + // stop the timer on the server side + ttcp_seq->stop_timer (); + + if (env.exception () != 0) + { + // env.print_exception ("stop_timer operation", stdout); + return -1; + } + // stop our timer + (void) read_timer (stats, sizeof (stats)); + + // print results + PrintStats(); + } + } + + CORBA::release (ttcp_seq); + CORBA::release (objref); + CORBA::release (orb_ptr); + } + catch(const CORBA::SystemException& exc) + { + ACE_DEBUG ((LM_DEBUG, + "CORBA::SystemException caught: %s (minor: %d): client.cpp\n\n", + exc._repository_id (), + exc.minor ())); + } + catch(const CORBA::UserException& exc) + { + ACE_DEBUG ((LM_DEBUG, + "CORBA::UserException caught: %s: client.cpp\n\n", + exc._repository_id ())); + } + catch(...) + { + ACE_DEBUG ((LM_DEBUG, + "Exception caught: client.cpp\n\n")); + } + + return (0); +} + +int print_usage (void) +{ + ACE_ERROR ((LM_ERROR, "Usage error\n")); + ACE_ERROR ((LM_ERROR, "%s\n", Usage)); + return -1; +} diff --git a/TAO/tests/Thruput/CORBAplus/extract b/TAO/tests/Thruput/CORBAplus/extract new file mode 100644 index 00000000000..f0fc2947b92 --- /dev/null +++ b/TAO/tests/Thruput/CORBAplus/extract @@ -0,0 +1,4 @@ +rm -f outfile +touch outfile +grep "Mbit/sec\|Send" results.CP | head -20 > outfile +grep "msec/call\|Send" results.CP | head -20 >> outfile diff --git a/TAO/tests/Thruput/CORBAplus/run b/TAO/tests/Thruput/CORBAplus/run new file mode 100644 index 00000000000..009677fdcde --- /dev/null +++ b/TAO/tests/Thruput/CORBAplus/run @@ -0,0 +1 @@ +client -S 67108864 -f m -l $1 -L temp -q $2 -d $3 diff --git a/TAO/tests/Thruput/CORBAplus/run_client b/TAO/tests/Thruput/CORBAplus/run_client new file mode 100644 index 00000000000..9e6932f8ae6 --- /dev/null +++ b/TAO/tests/Thruput/CORBAplus/run_client @@ -0,0 +1,25 @@ +#!/bin/csh -f +# All ATM tests: 64k socket Queue Size +# +# shorts +run_test 67108864 128 $1 ./results/REMOTE/$1/sun-iiop.atm.64 s $2 +sleep 5 +# longs +run_test 67108864 128 $1 ./results/REMOTE/$1/sun-iiop.atm.64 l $2 +sleep 5 +# octets +run_test 67108864 128 $1 ./results/REMOTE/$1/sun-iiop.atm.64 o $2 +sleep 5 +# doubles +run_test 67108864 128 $1 ./results/REMOTE/$1/sun-iiop.atm.64 d $2 +sleep 5 +# chars +#run_test 67108864 128 $1 ./results/REMOTE/$1/sun-iiop.atm.64 c $2 +#sleep 5 +# structures +run_test 67108864 128 $1 ./results/REMOTE/$1/sun-iiop.atm.64 S $2 +sleep 5 +# Composite Structs +#run_test 67108864 128 $1 ./results/REMOTE/$1/sun-iiop.atm.64 C $2 +#sleep 5 +# diff --git a/TAO/tests/Thruput/CORBAplus/run_server b/TAO/tests/Thruput/CORBAplus/run_server new file mode 100644 index 00000000000..e4faa5331e4 --- /dev/null +++ b/TAO/tests/Thruput/CORBAplus/run_server @@ -0,0 +1,10 @@ +#!/bin/csh +# +# Usage: server <switches> +# -u : use IOR +# -f m : output results in Mbps +# -b <sock Q size> ** not implemented ** +# -OAhost <host name> ************* must provide this for this version +# -OAthread : use threaded version as opposed to reactive +# +server -f m -ORBhost mambo.cs.wustl.edu #-OAthread diff --git a/TAO/tests/Thruput/CORBAplus/run_test b/TAO/tests/Thruput/CORBAplus/run_test new file mode 100644 index 00000000000..622b0b4fee6 --- /dev/null +++ b/TAO/tests/Thruput/CORBAplus/run_test @@ -0,0 +1,34 @@ +#!/bin/csh -f +echo $* +if ($#argv < 3) then + echo "Usage: sclt <Total Data Size> <Max msg size> <destination> <TitleOfThisTest> <seq type> <destination-port>" + exit 1 +endif +# +@ msize=1024 +@ limit= ($argv[2] * 1024) +#echo $limit +#echo $msize +test -d $4 || mkdir $4 +echo "Iteration#" 1 ": client -pbtrace -pbinit TTCP_IIOP_test iiop://$3:$6/TTCP_IIOP_test -S" $1 "-D -f m -s -t -l" $msize "-h" $3 "-x -L" $4 "-q" $5 -b 65536 +client -pbtrace -pbinit TTCP_IIOP_test iiop://$3:$6/TTCP_IIOP_test -S $1 -f m -l $msize -h $3 -L $4 -q $5 +set flag=0 +while ($msize <= $limit) + if ($flag == 0) goto label + echo "Iteration#" 1 ": client -pbtrace -pbinit TTCP_IIOP_test iiop://$3:$6/TTCP_IIOP_test -S" $1 "-D -f m -l" $msize "-h" $3 "-x -L" $4 "-q" $5 -b 65536 + client -pbtrace -pbinit TTCP_IIOP_test iiop://$3:$6/TTCP_IIOP_test -S $1 -f m -l $msize -h $3 -L $4 -q $5 + label: + set flag=1 + sleep 5 + foreach i (2) + echo "Iteration#" $i ": client -pbtrace -pbinit TTCP_IIOP_test iiop://$3:$6/TTCP_IIOP_test -S" $1 "-D -f m -s -t -l" $msize "-h" $3 "-x -L " $4 "-q" $5 -b 65536 + client -pbtrace -pbinit TTCP_IIOP_test iiop://$3:$6/TTCP_IIOP_test -S $1 -f m -l $msize -h $3 -L $4 -q $5 + end + echo "---------------------------" + @ msize = ($msize * 2) + sleep 5 +end + +echo " " +echo "Done at:" +date diff --git a/TAO/tests/Thruput/CORBAplus/run_tests b/TAO/tests/Thruput/CORBAplus/run_tests new file mode 100644 index 00000000000..515f420db91 --- /dev/null +++ b/TAO/tests/Thruput/CORBAplus/run_tests @@ -0,0 +1,36 @@ +#! /bin/csh + +rm -f results.CP +touch results.CP + +echo "CORBAplus throughput test" +echo "=========================" +echo "CORBAplus throughput test" >>& results.CP +echo "=========================" >>& results.CP + + +echo "Send Struct --------------------------------------------------------" >>& results.CP + ./client -S 10485760 -f m -l 1024 -h merengue-atm1 -L ./results/REMOTE/sun-iiop.atm.64 -q S -pbtrace -pbinit TTCP_IIOP_test iiop://merengue-atm1:58733/TTCP_IIOP_test >>& results.CP + ./client -S 10485760 -f m -l 2048 -h merengue-atm1 -L ./results/REMOTE/sun-iiop.atm.64 -q S -pbtrace -pbinit TTCP_IIOP_test iiop://merengue-atm1:58733/TTCP_IIOP_test >>& results.CP + ./client -S 10485760 -f m -l 4096 -h merengue-atm1 -L ./results/REMOTE/sun-iiop.atm.64 -q S -pbtrace -pbinit TTCP_IIOP_test iiop://merengue-atm1:58733/TTCP_IIOP_test >>& results.CP + ./client -S 10485760 -f m -l 8192 -h merengue-atm1 -L ./results/REMOTE/sun-iiop.atm.64 -q S -pbtrace -pbinit TTCP_IIOP_test iiop://merengue-atm1:58733/TTCP_IIOP_test >>& results.CP + ./client -S 10485760 -f m -l 16384 -h merengue-atm1 -L ./results/REMOTE/sun-iiop.atm.64 -q S -pbtrace -pbinit TTCP_IIOP_test iiop://merengue-atm1:58733/TTCP_IIOP_test >>& results.CP + ./client -S 10485760 -f m -l 32768 -h merengue-atm1 -L ./results/REMOTE/sun-iiop.atm.64 -q S -pbtrace -pbinit TTCP_IIOP_test iiop://merengue-atm1:58733/TTCP_IIOP_test >>& results.CP + ./client -S 10485760 -f m -l 65536 -h merengue-atm1 -L ./results/REMOTE/sun-iiop.atm.64 -q S -pbtrace -pbinit TTCP_IIOP_test iiop://merengue-atm1:58733/TTCP_IIOP_test >>& results.CP + ./client -S 10485760 -f m -l 131072 -h merengue-atm1 -L ./results/REMOTE/sun-iiop.atm.64 -q S -pbtrace -pbinit TTCP_IIOP_test iiop://merengue-atm1:58733/TTCP_IIOP_test >>& results.CP + ./client -S 10485760 -f m -l 262144 -h merengue-atm1 -L ./results/REMOTE/sun-iiop.atm.64 -q S -pbtrace -pbinit TTCP_IIOP_test iiop://merengue-atm1:58733/TTCP_IIOP_test >>& results.CP + +echo "Send Short ---------------------------------------------------------" >>& results.CP + ./client -S 10485760 -f m -l 1024 -h merengue-atm1 -L ./results/REMOTE/sun-iiop.atm.64 -q s -pbtrace -pbinit TTCP_IIOP_test iiop://merengue-atm1:58733/TTCP_IIOP_test >>& results.CP + ./client -S 10485760 -f m -l 2048 -h merengue-atm1 -L ./results/REMOTE/sun-iiop.atm.64 -q s -pbtrace -pbinit TTCP_IIOP_test iiop://merengue-atm1:58733/TTCP_IIOP_test >>& results.CP + ./client -S 10485760 -f m -l 4096 -h merengue-atm1 -L ./results/REMOTE/sun-iiop.atm.64 -q s -pbtrace -pbinit TTCP_IIOP_test iiop://merengue-atm1:58733/TTCP_IIOP_test >>& results.CP + ./client -S 10485760 -f m -l 8192 -h merengue-atm1 -L ./results/REMOTE/sun-iiop.atm.64 -q s -pbtrace -pbinit TTCP_IIOP_test iiop://merengue-atm1:58733/TTCP_IIOP_test >>& results.CP + ./client -S 10485760 -f m -l 16384 -h merengue-atm1 -L ./results/REMOTE/sun-iiop.atm.64 -q s -pbtrace -pbinit TTCP_IIOP_test iiop://merengue-atm1:58733/TTCP_IIOP_test >>& results.CP + ./client -S 10485760 -f m -l 32768 -h merengue-atm1 -L ./results/REMOTE/sun-iiop.atm.64 -q s -pbtrace -pbinit TTCP_IIOP_test iiop://merengue-atm1:58733/TTCP_IIOP_test >>& results.CP + ./client -S 10485760 -f m -l 65536 -h merengue-atm1 -L ./results/REMOTE/sun-iiop.atm.64 -q s -pbtrace -pbinit TTCP_IIOP_test iiop://merengue-atm1:58733/TTCP_IIOP_test >>& results.CP + ./client -S 10485760 -f m -l 131072 -h merengue-atm1 -L ./results/REMOTE/sun-iiop.atm.64 -q s -pbtrace -pbinit TTCP_IIOP_test iiop://merengue-atm1:58733/TTCP_IIOP_test >>& results.CP + ./client -S 10485760 -f m -l 262144 -h merengue-atm1 -L ./results/REMOTE/sun-iiop.atm.64 -q s -pbtrace -pbinit TTCP_IIOP_test iiop://merengue-atm1:58733/TTCP_IIOP_test >>& results.CP + + +grep "Mbit/sec\|Send" results.CP + diff --git a/TAO/tests/Thruput/CORBAplus/server.cpp b/TAO/tests/Thruput/CORBAplus/server.cpp new file mode 100644 index 00000000000..4d54a181ebc --- /dev/null +++ b/TAO/tests/Thruput/CORBAplus/server.cpp @@ -0,0 +1,176 @@ +// $Id$ +// ============================================================================ +// +// = TAO tests +// Throughput measurement using the TTCP benchmark adapted to work using TAO +// +// = FILENAME +// server.cpp +// +// = AUTHOR +// Aniruddha Gokhale +// +// ============================================================================ + +#include <iostream.h> +#include <fstream.h> + +#include <pbroker/corba/xpsorb.h> +#include <pbroker/corba/xpsboa.h> +#include <pbroker/corba/boad/boafull.h> // will force usage of "Full" BOA API +#include <pbroker/unixsvc/unixsvc.h> + +#include "ace/ACE.h" +#include "ttcp_i.h" +#include "ace/Get_Opt.h" + +char Usage[] = "\ +Usage: server [TAO options] [options] \n\ +Common options:\n\ +-l ## length of bufs read from or written to network (default 8192)\n\ +-v verbose: print more statistics\n\ +-d ## set debug level \n\ +-f X format for rate: k,K = kilo{bit,byte}; m,M = mega; g,G = giga\n\ +-L ## Output file name for the data type used\n\n\ +"; + +CORBA::Long trans = 0; // we are the receiver +CORBA::Long buflen = 8 * 1024; // length of buffer +CORBA::Char *buf; // ptr to dynamic buffer +CORBA::Long nbuf; // number of buffers to send in sinkmode +CORBA::Long verbose = 0; // 0=print basic info, 1=print cpu rate, proc + // resource usage. +CORBA::Char fmt = 'K'; // output format:k=kilobits,K=kilobytes, m = + // megabits, M = megabytes, g = gigabits, G = + // gigabytes + +char *title = 0; // results filename + +CORBA::Char stats[128]; // gathering the statistics +CORBA::ULong srcDataSize; // Total amount of source data +CORBA::ULong nbytes; // bytes on net +CORBA::ULong numCalls; // # of I/O system calls +CORBA::Double cput, realt; // user, real time (seconds) +CORBA::ULong dt; // data type + +/* declare struct variables for various message types */ +ttcp_sequence::ShortSeq *sseq; +ttcp_sequence::LongSeq *lseq; +ttcp_sequence::OctetSeq *oseq; +ttcp_sequence::DoubleSeq *dseq; +ttcp_sequence::CharSeq *cseq; +ttcp_sequence::StructSeq *Sseq; + +ttcp_sequence_i *my_ttcp; // instance of the target object + +u_int _debug_level = 0; + +// main program - Driver +int +main (int argc, char **argv) +{ + + int c; // option + CORBA::Environment env; // environment + XpsORB_ptr orb_ptr = XpsORB::_nil (); // handle to the ORB + XpsBOA * oa_ptr = XpsBOA::_nil (); // Object adapter + CORBA::String key = (CORBA::String) "key0"; // key assigned to our + // target object + CORBA::String str; // for stringified representation of the object reference + + ACE_UNUSED_ARG (key); + + try + { + // initialize the underlying ORB and get a handle to it + orb_ptr = XpsORB::init (argc, argv); + + // now get a handle to the object adapter + oa_ptr = XpsBOA::init (argc, argv); + + if (CORBA::is_nil(orb_ptr) || CORBA::is_nil(oa_ptr)) + { + ACE_ERROR_RETURN ((LM_ERROR, + " (%P|%t) Unable to initialize the ORB and/or the BOA\n"), + 1); + } + + // for parsing the arguments + ACE_Get_Opt get_opt (argc, argv, "l:vd:f:L:"); + + _debug_level = 0; + for (; (c = get_opt ()) != EOF;) + { + switch (c) + { + case 'L': + // title of output file that stores result + title = ACE_OS::strdup (get_opt.optarg); + break; + case 'd': + // debugging level + _debug_level = ACE_OS::atoi (get_opt.optarg); + if (_debug_level > 10) + _debug_level = 10; + break; + case 'f': + // output format i.e., Mbps, Kbps, etc + fmt = *get_opt.optarg; + break; + } + } + + // + // Receiver + // + + // create an instance of an object implementing the "ttcp" interface + my_ttcp = new ttcp_sequence_i ("TTCP_IIOP_test"); // this is its name + + if (1)//_debug_level > 0) + { + // get a stringified representation of the object reference created above + str = orb_ptr->object_to_url (my_ttcp); + ACE_DEBUG ((LM_DEBUG, "stringified obj reference = %s\n", str)); + } + +#if defined (USE_QUANTIFY) + // gather profile data + quantify_clear_data(); + quantify_start_recording_data(); +#endif + + oa_ptr->obj_is_ready (my_ttcp, nil); + oa_ptr->registerAlias (my_ttcp, "TTCP_IIOP_test"); + + // Handle requests for this object until we're killed, or one of the + // methods asks us to exit. + XpsEventService eventService; + eventService.mainloop(); // control will not return to this point + + } /* end of try() */ + catch(const CORBA::SystemException& exc) + { + ACE_DEBUG ((LM_DEBUG, + "CORBA::SystemException caught: %s (minor: %d): server.cpp\n\n", + exc._repository_id (), + exc.minor ())); + } + catch(const CORBA::UserException& exc) + { + ACE_DEBUG ((LM_DEBUG, + "CORBA::UserException caught: %s: server.cpp\n\n", + exc._repository_id ())); + } + catch(...) + { + ACE_DEBUG ((LM_DEBUG, + "Exception caught: server.cpp\n\n")); + } + + return 0; + + // usage: + // fprintf (stderr, Usage); + // return(1); +} diff --git a/TAO/tests/Thruput/CORBAplus/ttcp.idl b/TAO/tests/Thruput/CORBAplus/ttcp.idl new file mode 100644 index 00000000000..02f382f3d29 --- /dev/null +++ b/TAO/tests/Thruput/CORBAplus/ttcp.idl @@ -0,0 +1,34 @@ +/* -*- C++ -*- */ +struct BinStruct +{ + short s; + char c; + long l; + octet o; + double d; + // octet pad[8]; // to make it 32 bytes + // commented out until IDL support for arrays is added +}; + +// Richly typed data +interface ttcp_sequence +{ + typedef sequence<short> ShortSeq; + typedef sequence<long> LongSeq; + typedef sequence<double> DoubleSeq; + typedef sequence<char> CharSeq; + typedef sequence<octet> OctetSeq; + typedef sequence<BinStruct> StructSeq; + + + // Routines to send sequences of various data types + oneway void sendShortSeq (in ShortSeq ttcp_seq); + oneway void sendLongSeq (in LongSeq ttcp_seq); + oneway void sendDoubleSeq (in DoubleSeq ttcp_seq); + oneway void sendCharSeq (in CharSeq ttcp_seq); + oneway void sendOctetSeq (in OctetSeq ttcp_seq); + oneway void sendStructSeq (in StructSeq ttcp_seq); + + oneway void start_timer (); + oneway void stop_timer (); +}; diff --git a/TAO/tests/Thruput/CORBAplus/ttcp_decl.h b/TAO/tests/Thruput/CORBAplus/ttcp_decl.h new file mode 100644 index 00000000000..199580ed30d --- /dev/null +++ b/TAO/tests/Thruput/CORBAplus/ttcp_decl.h @@ -0,0 +1,76 @@ + +/* + * T T C P Header File + * + */ + +/* This file includes all the declarations and prototypes */ + +#ifndef _TTCP_DECL_H_ +#define _TTCP_DECL_H_ + +#include "ace/OS.h" +#include "ace/Profile_Timer.h" + +/* File to be included if Quantify is to be used */ +#if defined (USE_QUANTIFY) +#include <quantify.h> +#endif + + +/* define the data types to be sent */ +#define SEND_SHORT ((CORBA::ULong)(1)) +#define SEND_LONG ((CORBA::ULong)(2)) +#define SEND_CHAR ((CORBA::ULong)(3)) +#define SEND_OCTET ((CORBA::ULong)(4)) +#define SEND_DOUBLE ((CORBA::ULong)(5)) +#define SEND_STRUCT ((CORBA::ULong)(6)) +#define SEND_COMPOSITE ((CORBA::ULong)(7)) + +/************** +// Prototypes +***************/ +int err (char *s); +void mes (CORBA::Char *s); +char *outfmt (CORBA::Double b); +void prep_timer (void); +CORBA::Double read_timer (char *str, CORBA::Long len); +void prusage (register struct rusage *r0, struct rusage *r1, struct timeval *e, struct timeval *b, char *outp); +void tvadd (struct timeval *tsum, struct timeval *t0, struct timeval *t1); +void tvsub (struct timeval *tdiff, struct timeval *t1, struct timeval *t0); +void psecs (CORBA::Long l, register char *cp); +void delay (CORBA::Long us); +void FillPattern (register char *cp, register CORBA::Long bufLen, CORBA::ULong dt); +void PrintStats (void); + +/* Global variables defined here as extern */ +extern ACE_Svc_Export CORBA::Long trans; // whether we are transmitter + // or receiver +extern ACE_Svc_Export CORBA::Long buflen; /* length of buffer */ +extern ACE_Svc_Export char *buf; /* ptr to dynamic buffer */ +extern ACE_Svc_Export CORBA::Long nbuf; /* number of buffers to send in sinkmode */ +extern ACE_Svc_Export CORBA::Short port; /* TCP port number */ +extern ACE_Svc_Export char *host; /* ptr to name of host */ +extern ACE_Svc_Export CORBA::Long verbose; /* 0=print basic info, 1=prCORBA::Long cpu rate, proc + * resource usage. */ +extern ACE_Svc_Export CORBA::Char fmt; /* output format:k=kilobits,K=kilobytes, + * m = megabits, M = megabytes, + * g = gigabits, G = gigabytes */ +extern ACE_Svc_Export char *title; + +extern ACE_Svc_Export char stats[128]; +extern ACE_Svc_Export CORBA::ULong srcDataSize; /* Total amount of source data */ +extern ACE_Svc_Export CORBA::ULong nbytes; /* bytes on net */ +extern ACE_Svc_Export CORBA::ULong numCalls; /* # of I/O system calls */ +extern ACE_Svc_Export CORBA::Double cput, realt; /* user, real time (seconds) */ +extern ACE_Svc_Export CORBA::ULong dt; + +/* declare struct variables for various message types */ +extern ACE_Svc_Export ttcp_sequence::ShortSeq *sseq; +extern ACE_Svc_Export ttcp_sequence::LongSeq *lseq; +extern ACE_Svc_Export ttcp_sequence::OctetSeq *oseq; +extern ACE_Svc_Export ttcp_sequence::DoubleSeq *dseq; +extern ACE_Svc_Export ttcp_sequence::CharSeq *cseq; +extern ACE_Svc_Export ttcp_sequence::StructSeq *Sseq; + +#endif diff --git a/TAO/tests/Thruput/CORBAplus/ttcp_i.cpp b/TAO/tests/Thruput/CORBAplus/ttcp_i.cpp new file mode 100644 index 00000000000..8f8afaaeee9 --- /dev/null +++ b/TAO/tests/Thruput/CORBAplus/ttcp_i.cpp @@ -0,0 +1,103 @@ +#include "pbroker/corba/orb.h" +#include "pbroker/corba/environ.h" +#include <pbroker/corba/xpsboa.h> +#include <pbroker/corba/lifecycl/impldecl.h> +#include <iostream.h> +#include "ace/ACE.h" +#include "ttcp_i.h" +#include "ttcp_decl.h" + +/* the ttcp_i class implementation */ +ttcp_sequence_i::ttcp_sequence_i(const char *obj_name) + : key_(obj_name) +{ + this->nbytes_ = 0; + numCalls = 0; +} + +const char * +ttcp_sequence_i::_get_name (void) +{ + return key_; +} + +void +ttcp_sequence_i::start_timer (void) +{ + this->nbytes_ = 0; + ::prep_timer (); +} + +void +ttcp_sequence_i::stop_timer (void) +{ + (void) ::read_timer (stats, sizeof (stats)); + ::nbytes = this->nbytes_; + ::PrintStats(); + // reset + this->nbytes_ = 0; + numCalls = 0; +#if defined (USE_QUANTIFY) + quantify_stop_recording_data(); + ACE_Service_Config::end_reactor_event_loop(); + cerr << "*********** just before exiting " << endl; +#endif +#if defined (USE_PURIFY) + ACE_Service_Config::end_reactor_event_loop(); + cerr << "*********** just before exiting " << endl; +#endif +} + +void +ttcp_sequence_i::sendShortSeq(const ttcp_sequence::ShortSeq& ttcp_seq) +{ + numCalls++; + this->nbytes_ += ttcp_seq.length()*sizeof(CORBA::Short); +} + +void +ttcp_sequence_i::sendLongSeq(const ttcp_sequence::LongSeq& ttcp_seq) +{ + numCalls++; + this->nbytes_ += ttcp_seq.length()*sizeof(CORBA::Long) ; +} + +void +ttcp_sequence_i::sendOctetSeq(const ttcp_sequence::OctetSeq& ttcp_seq) +{ + numCalls++; + this->nbytes_ += ttcp_seq.length()*sizeof(CORBA::Octet) ; +} + +void +ttcp_sequence_i::sendDoubleSeq(const ttcp_sequence::DoubleSeq& ttcp_seq) +{ + numCalls++; + this->nbytes_ += ttcp_seq.length()*sizeof(CORBA::Double) ; +} + +void +ttcp_sequence_i::sendCharSeq(const ttcp_sequence::CharSeq& ttcp_seq) +{ + numCalls++; + this->nbytes_ += ttcp_seq.length()*sizeof(CORBA::Char) ; +} + +void +ttcp_sequence_i::sendStructSeq(const ttcp_sequence::StructSeq& ttcp_seq) +{ + numCalls++; + this->nbytes_ += ttcp_seq.length()*sizeof(BinStruct) ; +#ifdef DEBUG + // cout << "Bytes received so far = " << this->nbytes_ << endl; +#endif +} + + + + + + + + + diff --git a/TAO/tests/Thruput/CORBAplus/ttcp_i.h b/TAO/tests/Thruput/CORBAplus/ttcp_i.h new file mode 100644 index 00000000000..507c414349e --- /dev/null +++ b/TAO/tests/Thruput/CORBAplus/ttcp_i.h @@ -0,0 +1,59 @@ +// ============================================================================ +// +// = TAO tests +// Throughput measurement using the TTCP benchmark adapted to work using +// CORBAplus PowerBroker from Expersoft +// = FILENAME +// ttcp_i.h +// +// = AUTHOR +// Aniruddha Gokhale +// +// ============================================================================ + +#if !defined (TTCP_I_H) +#define TTCP_I_H + +#include <pbroker/corba/lifecycl/actvtr.h> +#include <pbroker/corba/lifecycl/impldecl.h> +#include "pbroker/corba/orb.h" +#include "pbroker/corba/request.h" +#include "pbroker/corba/environ.h" + +#include "ace/OS.h" +#include "ttcp_s.h" + +class ttcp_sequence_i: public ttcp_sequence_base_impl +{ +public: + // XPS_CAST1_DECL(ttcp_sequence_i,ttcp_sequence_base_impl) + // XPS_DEFINE_IMPLEMENTATION(ttcp_sequence_decl) + + ttcp_sequence_i(const char *obj_name); + + ttcp_sequence_i (void) + { ttcp_sequence_i ("keyone");} + + ttcp_sequence_i (const CORBA_ReferenceData & refData) + { ttcp_sequence_i ("keyone");} + + virtual void sendShortSeq (const ttcp_sequence::ShortSeq& ttcp_seq); + virtual void sendLongSeq (const ttcp_sequence::LongSeq& ttcp_seq); + virtual void sendDoubleSeq (const ttcp_sequence::DoubleSeq& ttcp_seq); + virtual void sendCharSeq (const ttcp_sequence::CharSeq& ttcp_seq); + virtual void sendStructSeq (const ttcp_sequence::StructSeq& ttcp_seq); + virtual void sendOctetSeq (const ttcp_sequence::OctetSeq& ttcp_seq); + + /* Routines to calculate the time required to transfer */ + virtual void start_timer (void); + virtual void stop_timer (void); + + const char *_get_name (void); + // get the key of the object. +private: + unsigned long nbytes_; + const char *key_; +}; + +#endif // defined (TTCP_I_H) + diff --git a/TAO/tests/Thruput/CORBAplus/utils.cpp b/TAO/tests/Thruput/CORBAplus/utils.cpp new file mode 100644 index 00000000000..3538bf2acb5 --- /dev/null +++ b/TAO/tests/Thruput/CORBAplus/utils.cpp @@ -0,0 +1,465 @@ +// ============================================================================ +// +// = TAO tests +// Throughput measurement using the TTCP benchmark adapted to work using TAO +// +// = FILENAME +// utils.cpp +// +// = AUTHOR +// Aniruddha Gokhale +// +// ============================================================================ + +// This file has all the helper functions that do the computation of +// throughput, system time used, user time, etc based on data collected. + +#include "ttcp.h" +#include "ttcp_decl.h" + +// the error function. +// displays the error message and exits +int err (char *s) +{ + ACE_OS::fprintf (stderr, "ttcp%s: ", trans ? "-t" : "-r"); + ACE_OS::perror (s); + ACE_OS::fprintf (stderr, "errno=%d\n", errno); + return -1; +} + +// prints a message indicating if it is a transmitter or a receiver +void mes (CORBA::String s) +{ + ACE_OS::fprintf (stderr, "ttcp%s: %s\n", trans ? "-t" : "-r", s); +} + +// does the formatting for the desired units in which the result is to be +// displayed +char * +outfmt (CORBA::Double b) +{ + static char obuf[50]; + switch (fmt) + { + case 'G': + ACE_OS::sprintf (obuf, "%.2f GB", b / 1024.0 / 1024.0 / 1024.0); + break; + default: + case 'K': + ACE_OS::sprintf (obuf, "%.2f KB", b / 1024.0); + break; + case 'M': + ACE_OS::sprintf (obuf, "%.2f MB", b / 1024.0 / 1024.0); + break; + case 'g': + ACE_OS::sprintf (obuf, "%.2f Gbit", b * 8.0 / 1024.0 / 1024.0 / 1024.0); + break; + case 'k': + ACE_OS::sprintf (obuf, "%.2f Kbit", b * 8.0 / 1024.0); + break; + case 'm': + ACE_OS::sprintf (obuf, "%.2f Mbit", b * 8.0 / 1024.0 / 1024.0); + break; + } + return obuf; +} + +static struct itimerval itime0; /* Time at which timing started */ +static struct rusage ru0; /* Resource utilization at the start */ + +/* + * P R E P _ T I M E R + */ +// this is in fact the internals of the "start_timer" operation +void +prep_timer (void) +{ + 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_usec = 0; + + + ACE_OS::getrusage (RUSAGE_SELF, &ru0); + + /* Init REAL Timer */ + if (setitimer (ITIMER_REAL, &itime0, NULL)) + { + perror ("Setting 'itimer' REAL failed"); + return; + } + +} + +/* + * R E A D _ T I M E R + * + */ +// This implements the internals of the "stop_timer" method +double +read_timer (char *str, CORBA::Long len) +{ + struct itimerval itimedol; + struct rusage ru1; + struct timeval td; + struct timeval tend, tstart; + char line[132]; + + ACE_OS::getrusage (RUSAGE_SELF, &ru1); + + if (getitimer (ITIMER_REAL, &itimedol)) + { + perror ("Getting 'itimer' REAL failed"); + return (0.0); + } + + prusage (&ru0, &ru1, &itime0.it_value, &itimedol.it_value, line); + (void) strncpy (str, line, len); + + /* Get real time */ + tvsub (&td, &itime0.it_value, &itimedol.it_value); + realt = td.tv_sec + ((double) td.tv_usec) / 1000000; + + /* Get CPU time (user+sys) */ + tvadd (&tend, &ru1.ru_utime, &ru1.ru_stime); + tvadd (&tstart, &ru0.ru_utime, &ru0.ru_stime); + tvsub (&td, &tend, &tstart); + cput = td.tv_sec + ((double) td.tv_usec) / 1000000; + if (cput < 0.00001) + cput = 0.00001; + return (cput); +} + +// prints the rusage stats +void +prusage (register struct rusage *r0, struct rusage *r1, + struct timeval *e, struct timeval *b, char *outp) +{ + struct timeval tdiff; + register time_t t; + register char *cp; + register int i; + 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; + 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 */ + cp = "%Uuser %Ssys %Ereal %P %Mmaxrss %F+%Rpf %Ccsw"; +#else + cp = "%Uuser %Ssys %Ereal %P %Xi+%Dd %Mmaxrss %F+%Rpf %Ccsw"; +#endif +#endif + for (; *cp; cp++) + { + if (*cp != '%') + *outp++ = *cp; + else if (cp[1]) + switch (*++cp) + { + + case 'U': + tvsub (&tdiff, &r1->ru_utime, &r0->ru_utime); + ACE_OS::sprintf (outp, "%d.%01d", tdiff.tv_sec, tdiff.tv_usec / 100000); + END (outp); + break; + + case 'S': + tvsub (&tdiff, &r1->ru_stime, &r0->ru_stime); + ACE_OS::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': + ACE_OS::sprintf (outp, "%d%%", (int) (t * 100 / ((ms ? ms : 1)))); + END (outp); + break; + +#if !defined(SYSV) + case 'W': + i = r1->ru_nswap - r0->ru_nswap; + ACE_OS::sprintf (outp, "%d", i); + END (outp); + break; + + case 'X': + ACE_OS::sprintf (outp, "%d", t == 0 ? 0 : (r1->ru_ixrss - r0->ru_ixrss) / t); + END (outp); + break; + + case 'D': + ACE_OS::sprintf (outp, "%d", t == 0 ? 0 : + (r1->ru_idrss + r1->ru_isrss - (r0->ru_idrss + r0->ru_isrss)) / t); + END (outp); + break; + + case 'K': + ACE_OS::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': + ACE_OS::sprintf (outp, "%d", r1->ru_maxrss / 2); + END (outp); + break; + + case 'F': + ACE_OS::sprintf (outp, "%d", r1->ru_majflt - r0->ru_majflt); + END (outp); + break; + + case 'R': + ACE_OS::sprintf (outp, "%d", r1->ru_minflt - r0->ru_minflt); + END (outp); + break; + + case 'I': + ACE_OS::sprintf (outp, "%d", r1->ru_inblock - r0->ru_inblock); + END (outp); + break; + + case 'O': + ACE_OS::sprintf (outp, "%d", r1->ru_oublock - r0->ru_oublock); + END (outp); + break; + case 'C': + ACE_OS::sprintf (outp, "%d+%d", r1->ru_nvcsw - r0->ru_nvcsw, + r1->ru_nivcsw - r0->ru_nivcsw); + END (outp); + break; +#endif /* !SYSV */ + } + } + *outp = '\0'; +} + +// adds two "timeval" structures +void +tvadd (struct timeval *tsum, struct timeval *t0, struct timeval *t1) +{ + + tsum->tv_sec = t0->tv_sec + t1->tv_sec; + tsum->tv_usec = t0->tv_usec + t1->tv_usec; + if (tsum->tv_usec > 1000000) + tsum->tv_sec++, tsum->tv_usec -= 1000000; +} + +// finds difference between two timevals +void +tvsub (struct timeval *tdiff, struct timeval *t1, struct timeval *t0) +{ + + tdiff->tv_sec = t1->tv_sec - t0->tv_sec; + tdiff->tv_usec = t1->tv_usec - t0->tv_usec; + if (tdiff->tv_usec < 0) + tdiff->tv_sec--, tdiff->tv_usec += 1000000; +} + +// print in seconds +void +psecs (CORBA::Long l, register char *cp) +{ + register int i; + + i = l / 3600; + if (i) + { + ACE_OS::sprintf (cp, "%d:", i); + END (cp); + i = l % 3600; + ACE_OS::sprintf (cp, "%d%d", (i / 60) / 10, (i / 60) % 10); + END (cp); + } + else + { + i = l; + ACE_OS::sprintf (cp, "%d", i / 60); + END (cp); + } + i %= 60; + *cp++ = ':'; + ACE_OS::sprintf (cp, "%d%d", i / 10, i % 10); +} + +// generate the specified delay in microseconds +void +delay (int us) +{ + struct timeval tv; + + tv.tv_sec = 0; + tv.tv_usec = us; + (void) select (1, (fd_set *) 0, (fd_set *) 0, (fd_set *) 0, &tv); +} + +// fill up a buffer with a data type that we want to send +void +FillPattern (register char *cp, register CORBA::Long bufLen, CORBA::ULong dt) +{ + unsigned long + num, i; + + switch(dt){ + case SEND_SHORT: + { + register short *SeqPtr = (short *)cp; + num = bufLen/sizeof(short); + for (i=0; i < num; i++) + SeqPtr[i] = (short)lrand48(); + sseq = new ttcp_sequence::ShortSeq(num,num, SeqPtr); + } + break; + case SEND_LONG: + { + register long *SeqPtr = (long *)cp; + num = bufLen/sizeof(long); + for (i=0; i < num; i++) + SeqPtr[i] = lrand48(); + lseq = new ttcp_sequence::LongSeq(num, num, SeqPtr); + } + break; + case SEND_DOUBLE: + { + register double *SeqPtr = (double *)cp; + num = bufLen/sizeof(double); + for (i=0; i < num; i++) + SeqPtr[i] = drand48(); + dseq = new ttcp_sequence::DoubleSeq(num, num, SeqPtr); + } + break; + case SEND_CHAR: + { + register CORBA::Char *SeqPtr = (CORBA::Char *)cp; + register char c = 0; + num = bufLen/sizeof(char); + for(i=0; i < num; i++){ + while (!isprint(c & 0x7f)) + c++; + SeqPtr[i] = (c++ & 0x7f); + } + cseq = new ttcp_sequence::CharSeq(num, num, SeqPtr); + } + break; + case SEND_STRUCT: + { + register BinStruct *SeqPtr = (BinStruct *)cp; + register char c = 0; + num = bufLen/sizeof(BinStruct); + for (i=0; i < num; i++){ + SeqPtr[i].s = (short)lrand48(); + SeqPtr[i].l = lrand48(); + SeqPtr[i].d = drand48(); + while (!isprint(c & 0x7f)) + c++; + SeqPtr[i].c = (c++ & 0x7f); + while (!isprint(c & 0x7f)) + c++; + SeqPtr[i].o = (unsigned char)(c++ & 0x7f); + } + Sseq = new ttcp_sequence::StructSeq(num, num, SeqPtr); + + } + break; + case SEND_OCTET: + default: + { + register CORBA::Octet *SeqPtr = (CORBA::Octet *)cp; + register char c = 0; + num = bufLen/sizeof(CORBA::Octet); + for(i=0; i < num; i++){ + while (!isprint(c & 0x7f)) + c++; + SeqPtr[i] = (c++ & 0x7f); + } + oseq = new ttcp_sequence::OctetSeq(num, num, SeqPtr); + } + break; + } +} + +// print all the statistics +void PrintStats (void) +{ + if (cput <= 0.0) + cput = 0.001; + if (realt <= 0.0) + realt = 0.001; + + if (title != 0) + { + double tmp; + FILE *outFile; + char filename[BUFSIZ]; + + strcpy(filename, title); + switch(dt){ + case SEND_SHORT: + strcat(filename, ".shortSeq.results"); + break; + case SEND_LONG: + strcat(filename, ".longSeq.results"); + break; + case SEND_DOUBLE: + strcat(filename, ".doubleSeq.results"); + break; + case SEND_CHAR: + strcat(filename, ".charSeq.results"); + break; + case SEND_STRUCT: + strcat(filename, ".structSeq.results"); + break; + case SEND_COMPOSITE: + strcat(filename, ".compositeSeq.results"); + break; + case SEND_OCTET: + default: + strcat(filename, ".octetSeq.results"); + break; + } + outFile = fopen (filename, "a+"); + ACE_OS::fprintf (outFile, "\n%ldk \t", buflen / 1024); + tmp = ((double) nbytes) / realt; + ACE_OS::fprintf (outFile, "%.2f ", tmp * 8.0 / 1024.0 / 1024.0); + fclose (outFile); + } + + ACE_OS::fprintf (stdout, + "ttcp%s: %ld bytes in %.2f real seconds = %s/sec +++\n", + trans ? "-t" : "-r", + nbytes, realt, outfmt (((double) nbytes) / realt)); + if (verbose) + { + ACE_OS::fprintf (stdout, + "ttcp%s: %ld bytes in %.2f CPU seconds = %s/cpu sec\n", + trans ? "-t" : "-r", + nbytes, cput, outfmt (((double) nbytes) / cput)); + } + ACE_OS::fprintf (stdout, + "ttcp%s: %d Server Method calls, msec/call = %.2f, calls/sec = %.2f\n", + trans ? "-t" : "-r", + numCalls, + 1024.0 * realt / ((double) numCalls), + ((double) numCalls) / realt); + ACE_OS::fprintf (stdout, "ttcp%s: %s\n", trans ? "-t" : "-r", stats); + if (verbose) + { + ACE_OS::fprintf (stdout, + "ttcp%s: buffer address %#x\n", + trans ? "-t" : "-r", + buf); + } +} |