summaryrefslogtreecommitdiff
path: root/TAO
diff options
context:
space:
mode:
authorgokhale <asgokhale@users.noreply.github.com>1997-07-02 04:07:32 +0000
committergokhale <asgokhale@users.noreply.github.com>1997-07-02 04:07:32 +0000
commit622fccc6a1e3a1d612e746ed7366953d042cf5c5 (patch)
tree521d149454d60b5c1a81d956762ab86dc98bbb97 /TAO
parent05e79889c71586362bd8c16348b2b03a4e3f48e1 (diff)
downloadATCD-622fccc6a1e3a1d612e746ed7366953d042cf5c5.tar.gz
VisiBroker cubit client
Diffstat (limited to 'TAO')
-rw-r--r--TAO/IIOP/tests/Cubit/VisiBroker/client/Makefile19
-rw-r--r--TAO/IIOP/tests/Cubit/VisiBroker/client/Profile_Timer.cpp127
-rw-r--r--TAO/IIOP/tests/Cubit/VisiBroker/client/Profile_Timer.h60
-rw-r--r--TAO/IIOP/tests/Cubit/VisiBroker/client/client.cpp230
-rw-r--r--TAO/IIOP/tests/Cubit/VisiBroker/client/cubit.idl40
-rw-r--r--TAO/IIOP/tests/Cubit/VisiBroker/client/stdmk36
-rw-r--r--TAO/tests/Cubit/VisiBroker/client/Makefile19
-rw-r--r--TAO/tests/Cubit/VisiBroker/client/Profile_Timer.cpp127
-rw-r--r--TAO/tests/Cubit/VisiBroker/client/Profile_Timer.h60
-rw-r--r--TAO/tests/Cubit/VisiBroker/client/client.cpp230
-rw-r--r--TAO/tests/Cubit/VisiBroker/client/cubit.idl40
-rw-r--r--TAO/tests/Cubit/VisiBroker/client/stdmk36
12 files changed, 1024 insertions, 0 deletions
diff --git a/TAO/IIOP/tests/Cubit/VisiBroker/client/Makefile b/TAO/IIOP/tests/Cubit/VisiBroker/client/Makefile
new file mode 100644
index 00000000000..d9c26fe56f0
--- /dev/null
+++ b/TAO/IIOP/tests/Cubit/VisiBroker/client/Makefile
@@ -0,0 +1,19 @@
+include stdmk
+
+EXE = client
+
+all: $(EXE)
+
+clean:
+ -rm -f core *.o cubitC.* cubitS.* $(EXE)
+ -rm -rf Templates.DB
+
+cubitS.cpp: cubit.idl
+ $(ORBCC) cubit.idl
+
+cubitC.cpp: cubit.idl
+ $(ORBCC) cubit.idl
+
+client: cubitC.o Profile_Timer.o client.o
+ $(CC) -o client cubitC.o Profile_Timer.o client.o \
+ $(LIBPATH) $(LIBORB) $(STDCC_LIBS)
diff --git a/TAO/IIOP/tests/Cubit/VisiBroker/client/Profile_Timer.cpp b/TAO/IIOP/tests/Cubit/VisiBroker/client/Profile_Timer.cpp
new file mode 100644
index 00000000000..526a3dc4efc
--- /dev/null
+++ b/TAO/IIOP/tests/Cubit/VisiBroker/client/Profile_Timer.cpp
@@ -0,0 +1,127 @@
+#include "Profile_Timer.h"
+
+/* Initialize interval timer. */
+
+Profile_Timer::Profile_Timer (void)
+{
+ char buf[20];
+ ::sprintf(buf, "/proc/%d", ::getpid ());
+
+ ::memset (&this->end_usage_, 0, sizeof this->end_usage_);
+ ::memset (&this->begin_usage_, 0, sizeof this->begin_usage_);
+ ::memset (&this->last_usage_, 0, sizeof this->last_usage_);
+ if ((this->proc_fd_ = ::open (buf, O_RDONLY, 0)) == -1)
+ ::perror (buf);
+}
+
+/* Terminate the interval timer. */
+Profile_Timer::~Profile_Timer (void)
+{
+ if (::close (this->proc_fd_) == -1)
+ ::perror ("Profile_Timer::~Profile_Timer");
+}
+
+/* Return the resource utilization. */
+
+void
+Profile_Timer::get_rusage (prusage_t &rusage)
+{
+ rusage = this->end_usage_;
+}
+
+/* Compute the amount of resource utilization since the start time. */
+
+void
+Profile_Timer::elapsed_rusage (prusage_t &rusage)
+{
+ rusage.pr_lwpid = this->end_usage_.pr_lwpid - this->last_usage_.pr_lwpid;
+ rusage.pr_count = this->end_usage_.pr_count - this->last_usage_.pr_count;
+ rusage.pr_minf = this->end_usage_.pr_minf - this->last_usage_.pr_minf;
+ rusage.pr_majf = this->end_usage_.pr_majf - this->last_usage_.pr_majf;
+ rusage.pr_inblk = this->end_usage_.pr_inblk - this->last_usage_.pr_inblk;
+ rusage.pr_oublk = this->end_usage_.pr_oublk - this->last_usage_.pr_oublk;
+ rusage.pr_msnd = this->end_usage_.pr_msnd - this->last_usage_.pr_msnd;
+ rusage.pr_mrcv = this->end_usage_.pr_mrcv - this->last_usage_.pr_mrcv;
+ rusage.pr_sigs = this->end_usage_.pr_sigs - this->last_usage_.pr_sigs;
+ this->subtract (rusage.pr_wtime, this->end_usage_.pr_wtime, this->last_usage_.pr_wtime);
+ this->subtract (rusage.pr_ltime, this->end_usage_.pr_ltime, this->last_usage_.pr_ltime);
+ this->subtract (rusage.pr_slptime, this->end_usage_.pr_slptime, this->last_usage_.pr_slptime);
+ rusage.pr_vctx = this->end_usage_.pr_vctx - this->last_usage_.pr_vctx;
+ rusage.pr_ictx = this->end_usage_.pr_ictx - this->last_usage_.pr_ictx;
+ rusage.pr_sysc = this->end_usage_.pr_sysc - this->last_usage_.pr_sysc;
+ rusage.pr_ioch = this->end_usage_.pr_ioch - this->last_usage_.pr_ioch;
+}
+
+/* Compute the elapsed time. */
+
+void
+Profile_Timer::compute_times (Elapsed_Time &et, prusage_t &end, prusage_t &begin)
+{
+ timestruc_t td;
+
+ this->subtract (td, end.pr_tstamp, begin.pr_tstamp);
+ et.real_time = td.tv_sec + ((double) td.tv_nsec) / (1000 * 1000 * 1000);
+ this->subtract (td, end.pr_utime, begin.pr_utime);
+ et.user_time = td.tv_sec + ((double) td.tv_nsec) / (1000 * 1000 * 1000);
+ this->subtract (td, end.pr_stime, begin.pr_stime);
+ et.system_time = td.tv_sec + ((double) td.tv_nsec) / (1000 * 1000 * 1000);
+}
+
+/* Compute the amount of time that has elapsed between start and stop. */
+
+int
+Profile_Timer::elapsed_time (Elapsed_Time &et)
+{
+ this->compute_times (et, this->end_usage_, this->begin_usage_);
+ return 0;
+}
+
+/* Determine the difference between T1 and T2. */
+
+void
+Profile_Timer::subtract (timestruc_t &tdiff, timestruc_t &t1, timestruc_t &t0)
+{
+ tdiff.tv_sec = t1.tv_sec - t0.tv_sec;
+ tdiff.tv_nsec = t1.tv_nsec - t0.tv_nsec;
+
+ /* Normalize the time. */
+
+ while (tdiff.tv_nsec < 0)
+ {
+ tdiff.tv_sec--;
+ tdiff.tv_nsec += (1000 * 1000 * 1000);
+ }
+}
+
+#if defined (DEBUG)
+#include <stdlib.h>
+extern "C" int gettimeofday (timeval *tp);
+
+const int DEFAULT_ITERATIONS = 1000000;
+
+int
+main (int argc, char *argv[])
+{
+ Profile_Timer timer;
+ int iterations = argc > 1 ? atoi (argv[1]) : DEFAULT_ITERATIONS;
+ timeval tv;
+
+ timer.start ();
+
+ for (int i = 0; i < iterations; i++)
+ gettimeofday (&tv);
+
+ timer.stop ();
+
+ Profile_Timer::Elapsed_Time et;
+
+ timer.elapsed_time (et);
+
+ printf ("iterations = %d\n", iterations);
+ printf ("real time = %f secs, user time = %f secs, system time = %f secs\n",
+ et.real_time, et.user_time, et.system_time);
+
+ printf ("time per call = %f usecs\n", (et.real_time / double (iterations)) * 1000000);
+ return 0;
+}
+#endif /* DEBUG */
diff --git a/TAO/IIOP/tests/Cubit/VisiBroker/client/Profile_Timer.h b/TAO/IIOP/tests/Cubit/VisiBroker/client/Profile_Timer.h
new file mode 100644
index 00000000000..b3aed157232
--- /dev/null
+++ b/TAO/IIOP/tests/Cubit/VisiBroker/client/Profile_Timer.h
@@ -0,0 +1,60 @@
+/* -*- C++ -*- */
+/* An interval timer class using C++. */
+
+#if !defined (ACE_PROFILE_TIMER_H)
+#define ACE_PROFILE_TIMER_H
+
+#include <sys/types.h>
+#include <unistd.h>
+#include <fcntl.h>
+#include <sys/procfs.h>
+#include <stdio.h>
+#include <memory.h>
+
+class Profile_Timer
+{
+public:
+ struct Elapsed_Time
+ {
+ double real_time;
+ double user_time;
+ double system_time;
+ };
+
+ Profile_Timer (void);
+ ~Profile_Timer (void);
+ int start (void);
+ int stop (void);
+ int elapsed_time (Elapsed_Time &et);
+ void elapsed_rusage (prusage_t &rusage);
+ void get_rusage (prusage_t &rusage);
+
+private:
+ void subtract (timestruc_t &tdiff, timestruc_t &t0, timestruc_t &t1);
+ void compute_times (Elapsed_Time &et, prusage_t &, prusage_t &);
+
+ prusage_t begin_usage_;
+ prusage_t end_usage_;
+ prusage_t last_usage_;
+ int proc_fd_;
+};
+
+/* Start timing */
+
+inline int
+Profile_Timer::start (void)
+{
+ return ::ioctl (this->proc_fd_, PIOCUSAGE, &this->begin_usage_);
+}
+
+/* Stop timing */
+
+inline int
+Profile_Timer::stop (void)
+{
+ this->last_usage_ = this->end_usage_;
+ return ::ioctl (this->proc_fd_, PIOCUSAGE, &this->end_usage_);
+}
+
+#endif /* ACE_PROFILE_TIMER_H */
+
diff --git a/TAO/IIOP/tests/Cubit/VisiBroker/client/client.cpp b/TAO/IIOP/tests/Cubit/VisiBroker/client/client.cpp
new file mode 100644
index 00000000000..c2b1d4070ae
--- /dev/null
+++ b/TAO/IIOP/tests/Cubit/VisiBroker/client/client.cpp
@@ -0,0 +1,230 @@
+//**************************************************************************
+//
+// NAME : client.C
+// DESCRIPTION:
+//
+// Client for the Cubit example
+//
+//****************************************************************************
+
+#include <iostream.h>
+#include <stdio.h>
+#include <string.h>
+#include <time.h>
+#include <stdlib.h>
+#include "cubitC.h"
+#include "Profile_Timer.h"
+
+int LOOP_COUNT;
+char SERVER_HOST [1024];
+
+inline int func (unsigned i) { return i - 117; }
+void run_tests (Cubit_var, int);
+
+// = TITLE
+// Parses the command line arguments and returns an error status
+//
+// = DESCRIPTION
+// This method parses the command line arguments
+int parse_args(int argc, char *argv[])
+{
+ if (argc != 3) {
+ cerr << "Format: client <machine name> <loop count>" << endl;
+ return -1;
+ }
+
+ strcpy(SERVER_HOST, argv[1]);
+
+ LOOP_COUNT = atoi(argv[2]);
+
+ return 0; // Indicates successful parsing of command line
+}
+
+
+//
+// Mainline
+//
+int
+main (int argc, char *argv[])
+{
+ if (parse_args (argc, argv) != 0)
+ return -1;
+
+ Cubit_var cb;
+ // cout << "attempting to contact server at host " << SERVER_HOST << '\n' ;
+
+ //
+ // Initialise client's binding to an
+ // arbitrary cubit server (at some host)
+ //
+ try {
+ cb = Cubit::_bind ("Cubit", SERVER_HOST);
+
+ } catch (const CORBA::Exception & sysEx) {
+ cerr << "Binding failed: " << endl;
+ cerr << sysEx;
+ } catch (...) {
+ cerr << "Unexpected exception" << endl;
+ }
+
+ run_tests (cb, LOOP_COUNT);
+ return 0;
+}
+
+
+void
+run_tests (Cubit_var cb, int loop_count)
+{
+ //
+ // Make the calls in a loop.
+ //
+ unsigned i;
+ unsigned call_count, error_count;
+
+ call_count = 0;
+ error_count = 0;
+
+ Profile_Timer pt;
+
+ pt.start();
+ //
+ // Cube an octet.
+ //
+
+ for (i = 0; i < loop_count; i++)
+ {
+
+ call_count++;
+
+ CORBA::Octet arg_octet = func (i), ret_octet;
+
+ try {
+ ret_octet = cb->cube_octet (arg_octet);
+
+ } catch (const CORBA::Exception &sysEx) {
+ cerr << "Call failed: " << endl;
+ cerr << sysEx;
+ error_count++;
+ } catch (...) {
+ cerr << "Unexpected exception" << endl;
+ error_count++;
+ }
+
+ arg_octet = arg_octet * arg_octet * arg_octet;
+ if (arg_octet != ret_octet) {
+ printf ("** cube_octet(%d) (--> %d)\n", arg_octet , ret_octet);
+ error_count++;
+ }
+
+
+ //
+ // Cube a short.
+ //
+ call_count++;
+
+ CORBA::Short arg_short = func (i), ret_short;
+
+ try {
+ ret_short = cb->cube_short (arg_short);
+
+ } catch (const CORBA::Exception &sysEx) {
+ cerr << "Call failed: " << endl;
+ cerr << sysEx;
+ error_count++;
+ } catch (...) {
+ cerr << "Unexpected exception" << endl;
+ error_count++;
+ }
+
+ arg_short = arg_short * arg_short * arg_short;
+ if (arg_short != ret_short) {
+ printf ("** cube_short(%d) (--> %d)\n", arg_short , ret_short);
+ error_count++;
+ }
+
+ //
+ // Cube a long.
+ //
+
+ call_count++;
+
+ CORBA::Long arg_long = func (i), ret_long;
+
+ try {
+ ret_long = cb->cube_long (arg_long);
+ } catch (const CORBA::Exception &sysEx) {
+ cerr << "Call failed: " << endl;
+ cerr << sysEx;
+ error_count++;
+ } catch (...) {
+ cerr << "Unexpected exception" << endl;
+ error_count++;
+ }
+
+ arg_long = arg_long * arg_long * arg_long;
+ if (arg_long != ret_long) {
+ printf ("** cube_long(%d) (--> %d)\n", arg_long , ret_long);
+ error_count++;
+ }
+
+
+ //
+ // Cube a "struct" ...
+ //
+ Cubit::Many arg_struct, ret_struct;
+
+ call_count++;
+
+ arg_struct.l = func (i);
+ arg_struct.s = func (i);
+ arg_struct.o = func (i);
+
+ try {
+ ret_struct = cb->cube_struct (arg_struct);
+
+ } catch (const CORBA::Exception &sysEx) {
+ cerr << "Call failed: " << endl;
+ cerr << sysEx;
+ error_count++;
+ } catch (...) {
+ cerr << "Unexpected exception" << endl;
+ error_count++;
+ }
+
+
+ arg_struct.l = arg_struct.l * arg_struct.l * arg_struct.l ;
+ arg_struct.s = arg_struct.s * arg_struct.s * arg_struct.s ;
+ arg_struct.o = arg_struct.o * arg_struct.o * arg_struct.o ;
+
+ if (arg_struct.l != ret_struct.l
+ || arg_struct.s != ret_struct.s
+ || arg_struct.o != ret_struct.o )
+ {
+ cerr << "** cube_struct ERROR\n";
+ error_count++;
+ }
+ }
+
+ pt.stop();
+
+ Elapsed_Time et;
+ pt.elapsed_time(et);
+
+ if (call_count > 0)
+ {
+ if (error_count == 0)
+ {
+ unsigned long us = et.real_time * 1000 * 1000;
+
+ us /= call_count;
+
+ if (us > 0)
+ printf ("cube average call ACE_OS::time\t= %ld.%.03ldms, \t"
+ "%ld calls/second\n",
+ us / 1000, us % 1000,
+ 1000000L / us);
+ }
+
+ printf ("%d calls, %d errors\n", call_count, error_count);
+ }
+}
diff --git a/TAO/IIOP/tests/Cubit/VisiBroker/client/cubit.idl b/TAO/IIOP/tests/Cubit/VisiBroker/client/cubit.idl
new file mode 100644
index 00000000000..3e2ea392619
--- /dev/null
+++ b/TAO/IIOP/tests/Cubit/VisiBroker/client/cubit.idl
@@ -0,0 +1,40 @@
+// @(#)cubit.idl 1.1 95/09/10
+// Copyright 1994-1995 by Sun Microsystems, Inc.
+//
+//#pragma prefix "Eng.SUN.COM"
+//#pragma version Cubit 1.1
+
+interface Cubit {
+ octet cube_octet (in octet o);
+ short cube_short (in short s);
+ long cube_long (in long l);
+
+ struct Many {
+ octet o; // + 3 bytes padding (normally) ...
+ long l;
+ short s; // + 2 bytes padding (normally) ...
+ };
+
+ Many cube_struct (in Many values);
+
+ enum discrim {e_0th, e_1st, e_2nd, e_3rd, e_4th, e_5th};
+
+ union oneof
+ switch (discrim) {
+ // this is an easy union to interpret; no padding
+ // is needed between discriminant and value.
+ case e_0th:
+ octet o;
+ case e_1st:
+ short s;
+ case e_2nd:
+ long l;
+ case e_3rd:
+ default:
+ Many cm;
+ };
+
+ oneof cube_union (in oneof values);
+
+ oneway void please_exit ();
+};
diff --git a/TAO/IIOP/tests/Cubit/VisiBroker/client/stdmk b/TAO/IIOP/tests/Cubit/VisiBroker/client/stdmk
new file mode 100644
index 00000000000..df4125a38d8
--- /dev/null
+++ b/TAO/IIOP/tests/Cubit/VisiBroker/client/stdmk
@@ -0,0 +1,36 @@
+CC = CC
+DEBUG =
+
+ORBELINEDIR = /project/waltz/Orbeline2.0
+
+ORBCC = $(ORBELINEDIR)/bin/orbeline -v C -m S -c cpp -h h
+
+CCINCLUDES = -I. -I$(ORBELINEDIR)/include -I$(STL_DIR) -I$(ACE_DIR)
+
+CCFLAGS = -g $(CCINCLUDES) $(DEBUG) -DCubit_USE_BOA
+
+LIBPATH = -L$(ORBELINEDIR)/lib -L$(ACE_DIR)/ace
+
+STDCC_LIBS = -lsocket -lnsl -ldl -mt
+
+LIBORB = -lorb
+
+LIBACE = -lACE
+
+.SUFFIXES: .C .o .h .hh .cc .cpp
+
+.C.o:
+ $(CC) $(CCFLAGS) -c -o $@ $<
+
+.cc.o:
+ $(CC) $(CCFLAGS) -c -o $@ $<
+.cpp.o:
+ $(CC) $(CCFLAGS) -c -o $@ $<
+
+.C.cpp:
+ $(CC) -E $(CCFLAGS) $< > $@
+
+.cc.cpp:
+ $(CC) -E $(CCFLAGS) $< > $@
+
+
diff --git a/TAO/tests/Cubit/VisiBroker/client/Makefile b/TAO/tests/Cubit/VisiBroker/client/Makefile
new file mode 100644
index 00000000000..d9c26fe56f0
--- /dev/null
+++ b/TAO/tests/Cubit/VisiBroker/client/Makefile
@@ -0,0 +1,19 @@
+include stdmk
+
+EXE = client
+
+all: $(EXE)
+
+clean:
+ -rm -f core *.o cubitC.* cubitS.* $(EXE)
+ -rm -rf Templates.DB
+
+cubitS.cpp: cubit.idl
+ $(ORBCC) cubit.idl
+
+cubitC.cpp: cubit.idl
+ $(ORBCC) cubit.idl
+
+client: cubitC.o Profile_Timer.o client.o
+ $(CC) -o client cubitC.o Profile_Timer.o client.o \
+ $(LIBPATH) $(LIBORB) $(STDCC_LIBS)
diff --git a/TAO/tests/Cubit/VisiBroker/client/Profile_Timer.cpp b/TAO/tests/Cubit/VisiBroker/client/Profile_Timer.cpp
new file mode 100644
index 00000000000..526a3dc4efc
--- /dev/null
+++ b/TAO/tests/Cubit/VisiBroker/client/Profile_Timer.cpp
@@ -0,0 +1,127 @@
+#include "Profile_Timer.h"
+
+/* Initialize interval timer. */
+
+Profile_Timer::Profile_Timer (void)
+{
+ char buf[20];
+ ::sprintf(buf, "/proc/%d", ::getpid ());
+
+ ::memset (&this->end_usage_, 0, sizeof this->end_usage_);
+ ::memset (&this->begin_usage_, 0, sizeof this->begin_usage_);
+ ::memset (&this->last_usage_, 0, sizeof this->last_usage_);
+ if ((this->proc_fd_ = ::open (buf, O_RDONLY, 0)) == -1)
+ ::perror (buf);
+}
+
+/* Terminate the interval timer. */
+Profile_Timer::~Profile_Timer (void)
+{
+ if (::close (this->proc_fd_) == -1)
+ ::perror ("Profile_Timer::~Profile_Timer");
+}
+
+/* Return the resource utilization. */
+
+void
+Profile_Timer::get_rusage (prusage_t &rusage)
+{
+ rusage = this->end_usage_;
+}
+
+/* Compute the amount of resource utilization since the start time. */
+
+void
+Profile_Timer::elapsed_rusage (prusage_t &rusage)
+{
+ rusage.pr_lwpid = this->end_usage_.pr_lwpid - this->last_usage_.pr_lwpid;
+ rusage.pr_count = this->end_usage_.pr_count - this->last_usage_.pr_count;
+ rusage.pr_minf = this->end_usage_.pr_minf - this->last_usage_.pr_minf;
+ rusage.pr_majf = this->end_usage_.pr_majf - this->last_usage_.pr_majf;
+ rusage.pr_inblk = this->end_usage_.pr_inblk - this->last_usage_.pr_inblk;
+ rusage.pr_oublk = this->end_usage_.pr_oublk - this->last_usage_.pr_oublk;
+ rusage.pr_msnd = this->end_usage_.pr_msnd - this->last_usage_.pr_msnd;
+ rusage.pr_mrcv = this->end_usage_.pr_mrcv - this->last_usage_.pr_mrcv;
+ rusage.pr_sigs = this->end_usage_.pr_sigs - this->last_usage_.pr_sigs;
+ this->subtract (rusage.pr_wtime, this->end_usage_.pr_wtime, this->last_usage_.pr_wtime);
+ this->subtract (rusage.pr_ltime, this->end_usage_.pr_ltime, this->last_usage_.pr_ltime);
+ this->subtract (rusage.pr_slptime, this->end_usage_.pr_slptime, this->last_usage_.pr_slptime);
+ rusage.pr_vctx = this->end_usage_.pr_vctx - this->last_usage_.pr_vctx;
+ rusage.pr_ictx = this->end_usage_.pr_ictx - this->last_usage_.pr_ictx;
+ rusage.pr_sysc = this->end_usage_.pr_sysc - this->last_usage_.pr_sysc;
+ rusage.pr_ioch = this->end_usage_.pr_ioch - this->last_usage_.pr_ioch;
+}
+
+/* Compute the elapsed time. */
+
+void
+Profile_Timer::compute_times (Elapsed_Time &et, prusage_t &end, prusage_t &begin)
+{
+ timestruc_t td;
+
+ this->subtract (td, end.pr_tstamp, begin.pr_tstamp);
+ et.real_time = td.tv_sec + ((double) td.tv_nsec) / (1000 * 1000 * 1000);
+ this->subtract (td, end.pr_utime, begin.pr_utime);
+ et.user_time = td.tv_sec + ((double) td.tv_nsec) / (1000 * 1000 * 1000);
+ this->subtract (td, end.pr_stime, begin.pr_stime);
+ et.system_time = td.tv_sec + ((double) td.tv_nsec) / (1000 * 1000 * 1000);
+}
+
+/* Compute the amount of time that has elapsed between start and stop. */
+
+int
+Profile_Timer::elapsed_time (Elapsed_Time &et)
+{
+ this->compute_times (et, this->end_usage_, this->begin_usage_);
+ return 0;
+}
+
+/* Determine the difference between T1 and T2. */
+
+void
+Profile_Timer::subtract (timestruc_t &tdiff, timestruc_t &t1, timestruc_t &t0)
+{
+ tdiff.tv_sec = t1.tv_sec - t0.tv_sec;
+ tdiff.tv_nsec = t1.tv_nsec - t0.tv_nsec;
+
+ /* Normalize the time. */
+
+ while (tdiff.tv_nsec < 0)
+ {
+ tdiff.tv_sec--;
+ tdiff.tv_nsec += (1000 * 1000 * 1000);
+ }
+}
+
+#if defined (DEBUG)
+#include <stdlib.h>
+extern "C" int gettimeofday (timeval *tp);
+
+const int DEFAULT_ITERATIONS = 1000000;
+
+int
+main (int argc, char *argv[])
+{
+ Profile_Timer timer;
+ int iterations = argc > 1 ? atoi (argv[1]) : DEFAULT_ITERATIONS;
+ timeval tv;
+
+ timer.start ();
+
+ for (int i = 0; i < iterations; i++)
+ gettimeofday (&tv);
+
+ timer.stop ();
+
+ Profile_Timer::Elapsed_Time et;
+
+ timer.elapsed_time (et);
+
+ printf ("iterations = %d\n", iterations);
+ printf ("real time = %f secs, user time = %f secs, system time = %f secs\n",
+ et.real_time, et.user_time, et.system_time);
+
+ printf ("time per call = %f usecs\n", (et.real_time / double (iterations)) * 1000000);
+ return 0;
+}
+#endif /* DEBUG */
diff --git a/TAO/tests/Cubit/VisiBroker/client/Profile_Timer.h b/TAO/tests/Cubit/VisiBroker/client/Profile_Timer.h
new file mode 100644
index 00000000000..b3aed157232
--- /dev/null
+++ b/TAO/tests/Cubit/VisiBroker/client/Profile_Timer.h
@@ -0,0 +1,60 @@
+/* -*- C++ -*- */
+/* An interval timer class using C++. */
+
+#if !defined (ACE_PROFILE_TIMER_H)
+#define ACE_PROFILE_TIMER_H
+
+#include <sys/types.h>
+#include <unistd.h>
+#include <fcntl.h>
+#include <sys/procfs.h>
+#include <stdio.h>
+#include <memory.h>
+
+class Profile_Timer
+{
+public:
+ struct Elapsed_Time
+ {
+ double real_time;
+ double user_time;
+ double system_time;
+ };
+
+ Profile_Timer (void);
+ ~Profile_Timer (void);
+ int start (void);
+ int stop (void);
+ int elapsed_time (Elapsed_Time &et);
+ void elapsed_rusage (prusage_t &rusage);
+ void get_rusage (prusage_t &rusage);
+
+private:
+ void subtract (timestruc_t &tdiff, timestruc_t &t0, timestruc_t &t1);
+ void compute_times (Elapsed_Time &et, prusage_t &, prusage_t &);
+
+ prusage_t begin_usage_;
+ prusage_t end_usage_;
+ prusage_t last_usage_;
+ int proc_fd_;
+};
+
+/* Start timing */
+
+inline int
+Profile_Timer::start (void)
+{
+ return ::ioctl (this->proc_fd_, PIOCUSAGE, &this->begin_usage_);
+}
+
+/* Stop timing */
+
+inline int
+Profile_Timer::stop (void)
+{
+ this->last_usage_ = this->end_usage_;
+ return ::ioctl (this->proc_fd_, PIOCUSAGE, &this->end_usage_);
+}
+
+#endif /* ACE_PROFILE_TIMER_H */
+
diff --git a/TAO/tests/Cubit/VisiBroker/client/client.cpp b/TAO/tests/Cubit/VisiBroker/client/client.cpp
new file mode 100644
index 00000000000..c2b1d4070ae
--- /dev/null
+++ b/TAO/tests/Cubit/VisiBroker/client/client.cpp
@@ -0,0 +1,230 @@
+//**************************************************************************
+//
+// NAME : client.C
+// DESCRIPTION:
+//
+// Client for the Cubit example
+//
+//****************************************************************************
+
+#include <iostream.h>
+#include <stdio.h>
+#include <string.h>
+#include <time.h>
+#include <stdlib.h>
+#include "cubitC.h"
+#include "Profile_Timer.h"
+
+int LOOP_COUNT;
+char SERVER_HOST [1024];
+
+inline int func (unsigned i) { return i - 117; }
+void run_tests (Cubit_var, int);
+
+// = TITLE
+// Parses the command line arguments and returns an error status
+//
+// = DESCRIPTION
+// This method parses the command line arguments
+int parse_args(int argc, char *argv[])
+{
+ if (argc != 3) {
+ cerr << "Format: client <machine name> <loop count>" << endl;
+ return -1;
+ }
+
+ strcpy(SERVER_HOST, argv[1]);
+
+ LOOP_COUNT = atoi(argv[2]);
+
+ return 0; // Indicates successful parsing of command line
+}
+
+
+//
+// Mainline
+//
+int
+main (int argc, char *argv[])
+{
+ if (parse_args (argc, argv) != 0)
+ return -1;
+
+ Cubit_var cb;
+ // cout << "attempting to contact server at host " << SERVER_HOST << '\n' ;
+
+ //
+ // Initialise client's binding to an
+ // arbitrary cubit server (at some host)
+ //
+ try {
+ cb = Cubit::_bind ("Cubit", SERVER_HOST);
+
+ } catch (const CORBA::Exception & sysEx) {
+ cerr << "Binding failed: " << endl;
+ cerr << sysEx;
+ } catch (...) {
+ cerr << "Unexpected exception" << endl;
+ }
+
+ run_tests (cb, LOOP_COUNT);
+ return 0;
+}
+
+
+void
+run_tests (Cubit_var cb, int loop_count)
+{
+ //
+ // Make the calls in a loop.
+ //
+ unsigned i;
+ unsigned call_count, error_count;
+
+ call_count = 0;
+ error_count = 0;
+
+ Profile_Timer pt;
+
+ pt.start();
+ //
+ // Cube an octet.
+ //
+
+ for (i = 0; i < loop_count; i++)
+ {
+
+ call_count++;
+
+ CORBA::Octet arg_octet = func (i), ret_octet;
+
+ try {
+ ret_octet = cb->cube_octet (arg_octet);
+
+ } catch (const CORBA::Exception &sysEx) {
+ cerr << "Call failed: " << endl;
+ cerr << sysEx;
+ error_count++;
+ } catch (...) {
+ cerr << "Unexpected exception" << endl;
+ error_count++;
+ }
+
+ arg_octet = arg_octet * arg_octet * arg_octet;
+ if (arg_octet != ret_octet) {
+ printf ("** cube_octet(%d) (--> %d)\n", arg_octet , ret_octet);
+ error_count++;
+ }
+
+
+ //
+ // Cube a short.
+ //
+ call_count++;
+
+ CORBA::Short arg_short = func (i), ret_short;
+
+ try {
+ ret_short = cb->cube_short (arg_short);
+
+ } catch (const CORBA::Exception &sysEx) {
+ cerr << "Call failed: " << endl;
+ cerr << sysEx;
+ error_count++;
+ } catch (...) {
+ cerr << "Unexpected exception" << endl;
+ error_count++;
+ }
+
+ arg_short = arg_short * arg_short * arg_short;
+ if (arg_short != ret_short) {
+ printf ("** cube_short(%d) (--> %d)\n", arg_short , ret_short);
+ error_count++;
+ }
+
+ //
+ // Cube a long.
+ //
+
+ call_count++;
+
+ CORBA::Long arg_long = func (i), ret_long;
+
+ try {
+ ret_long = cb->cube_long (arg_long);
+ } catch (const CORBA::Exception &sysEx) {
+ cerr << "Call failed: " << endl;
+ cerr << sysEx;
+ error_count++;
+ } catch (...) {
+ cerr << "Unexpected exception" << endl;
+ error_count++;
+ }
+
+ arg_long = arg_long * arg_long * arg_long;
+ if (arg_long != ret_long) {
+ printf ("** cube_long(%d) (--> %d)\n", arg_long , ret_long);
+ error_count++;
+ }
+
+
+ //
+ // Cube a "struct" ...
+ //
+ Cubit::Many arg_struct, ret_struct;
+
+ call_count++;
+
+ arg_struct.l = func (i);
+ arg_struct.s = func (i);
+ arg_struct.o = func (i);
+
+ try {
+ ret_struct = cb->cube_struct (arg_struct);
+
+ } catch (const CORBA::Exception &sysEx) {
+ cerr << "Call failed: " << endl;
+ cerr << sysEx;
+ error_count++;
+ } catch (...) {
+ cerr << "Unexpected exception" << endl;
+ error_count++;
+ }
+
+
+ arg_struct.l = arg_struct.l * arg_struct.l * arg_struct.l ;
+ arg_struct.s = arg_struct.s * arg_struct.s * arg_struct.s ;
+ arg_struct.o = arg_struct.o * arg_struct.o * arg_struct.o ;
+
+ if (arg_struct.l != ret_struct.l
+ || arg_struct.s != ret_struct.s
+ || arg_struct.o != ret_struct.o )
+ {
+ cerr << "** cube_struct ERROR\n";
+ error_count++;
+ }
+ }
+
+ pt.stop();
+
+ Elapsed_Time et;
+ pt.elapsed_time(et);
+
+ if (call_count > 0)
+ {
+ if (error_count == 0)
+ {
+ unsigned long us = et.real_time * 1000 * 1000;
+
+ us /= call_count;
+
+ if (us > 0)
+ printf ("cube average call ACE_OS::time\t= %ld.%.03ldms, \t"
+ "%ld calls/second\n",
+ us / 1000, us % 1000,
+ 1000000L / us);
+ }
+
+ printf ("%d calls, %d errors\n", call_count, error_count);
+ }
+}
diff --git a/TAO/tests/Cubit/VisiBroker/client/cubit.idl b/TAO/tests/Cubit/VisiBroker/client/cubit.idl
new file mode 100644
index 00000000000..3e2ea392619
--- /dev/null
+++ b/TAO/tests/Cubit/VisiBroker/client/cubit.idl
@@ -0,0 +1,40 @@
+// @(#)cubit.idl 1.1 95/09/10
+// Copyright 1994-1995 by Sun Microsystems, Inc.
+//
+//#pragma prefix "Eng.SUN.COM"
+//#pragma version Cubit 1.1
+
+interface Cubit {
+ octet cube_octet (in octet o);
+ short cube_short (in short s);
+ long cube_long (in long l);
+
+ struct Many {
+ octet o; // + 3 bytes padding (normally) ...
+ long l;
+ short s; // + 2 bytes padding (normally) ...
+ };
+
+ Many cube_struct (in Many values);
+
+ enum discrim {e_0th, e_1st, e_2nd, e_3rd, e_4th, e_5th};
+
+ union oneof
+ switch (discrim) {
+ // this is an easy union to interpret; no padding
+ // is needed between discriminant and value.
+ case e_0th:
+ octet o;
+ case e_1st:
+ short s;
+ case e_2nd:
+ long l;
+ case e_3rd:
+ default:
+ Many cm;
+ };
+
+ oneof cube_union (in oneof values);
+
+ oneway void please_exit ();
+};
diff --git a/TAO/tests/Cubit/VisiBroker/client/stdmk b/TAO/tests/Cubit/VisiBroker/client/stdmk
new file mode 100644
index 00000000000..df4125a38d8
--- /dev/null
+++ b/TAO/tests/Cubit/VisiBroker/client/stdmk
@@ -0,0 +1,36 @@
+CC = CC
+DEBUG =
+
+ORBELINEDIR = /project/waltz/Orbeline2.0
+
+ORBCC = $(ORBELINEDIR)/bin/orbeline -v C -m S -c cpp -h h
+
+CCINCLUDES = -I. -I$(ORBELINEDIR)/include -I$(STL_DIR) -I$(ACE_DIR)
+
+CCFLAGS = -g $(CCINCLUDES) $(DEBUG) -DCubit_USE_BOA
+
+LIBPATH = -L$(ORBELINEDIR)/lib -L$(ACE_DIR)/ace
+
+STDCC_LIBS = -lsocket -lnsl -ldl -mt
+
+LIBORB = -lorb
+
+LIBACE = -lACE
+
+.SUFFIXES: .C .o .h .hh .cc .cpp
+
+.C.o:
+ $(CC) $(CCFLAGS) -c -o $@ $<
+
+.cc.o:
+ $(CC) $(CCFLAGS) -c -o $@ $<
+.cpp.o:
+ $(CC) $(CCFLAGS) -c -o $@ $<
+
+.C.cpp:
+ $(CC) -E $(CCFLAGS) $< > $@
+
+.cc.cpp:
+ $(CC) -E $(CCFLAGS) $< > $@
+
+