diff options
author | nanbor <nanbor@ae88bc3d-4319-0410-8dbf-d08b4c9d3795> | 1998-06-26 07:18:06 +0000 |
---|---|---|
committer | nanbor <nanbor@ae88bc3d-4319-0410-8dbf-d08b4c9d3795> | 1998-06-26 07:18:06 +0000 |
commit | b94850b4e5ea99acd33ea52c152af6a6b06b53b4 (patch) | |
tree | 0c3309616d487eb9d578d6d4818c9f20d2bbd517 /performance-tests/Synch-Benchmarks | |
parent | 243c14eef149d5815fadf4fa01e69b18e853409d (diff) | |
download | ATCD-b94850b4e5ea99acd33ea52c152af6a6b06b53b4.tar.gz |
Extending benchmark suite
Diffstat (limited to 'performance-tests/Synch-Benchmarks')
-rw-r--r-- | performance-tests/Synch-Benchmarks/Benchmark.cpp | 41 | ||||
-rw-r--r-- | performance-tests/Synch-Benchmarks/Benchmark.h | 39 | ||||
-rw-r--r-- | performance-tests/Synch-Benchmarks/Benchmark_Base.cpp | 63 | ||||
-rw-r--r-- | performance-tests/Synch-Benchmarks/Benchmark_Base.h | 78 | ||||
-rw-r--r-- | performance-tests/Synch-Benchmarks/Makefile | 5 |
5 files changed, 146 insertions, 80 deletions
diff --git a/performance-tests/Synch-Benchmarks/Benchmark.cpp b/performance-tests/Synch-Benchmarks/Benchmark.cpp index 54b82c346b8..bd3cb8a9a92 100644 --- a/performance-tests/Synch-Benchmarks/Benchmark.cpp +++ b/performance-tests/Synch-Benchmarks/Benchmark.cpp @@ -19,17 +19,6 @@ Benchmark::done (void) return Benchmark::done_; } -int -Benchmark::thr_id (void) -{ -#if defined (ACE_HAS_PTHREADS) || defined (ACE_HAS_DCETHREADS) || defined (VXWORKS) - // This invokes the thread-specific storage smart pointer. - return this->id_->thr_id (); -#else - return ACE_Thread::self (); -#endif /* ACE_HAS_PTHREADS || ACE_HAS_DCETHREADS || VXWORKS */ -} - void Benchmark::done (sig_atomic_t d) { @@ -66,34 +55,4 @@ Benchmark::svc_run (Benchmark *bp) return (void *) (bp->svc () == -1 ? -1 : 0); } -#if defined (ACE_HAS_PTHREADS) || defined (ACE_HAS_DCETHREADS) || defined (VXWORKS) -/* static */ -MT_INT Thr_ID::thread_id_ (0); - -Thr_ID::Thr_ID (void) - : thr_id_ (++Thr_ID::thread_id_) -{ -} - -int -Thr_ID::thr_id (void) -{ - return this->thr_id_; -} - -void -Thr_ID::thr_id (int i) -{ - this->thr_id_ = i; -} - -#if defined (ACE_HAS_EXPLICIT_TEMPLATE_INSTANTIATION) -template class ACE_TSS<Thr_ID>; -template class ACE_Atomic_Op<ACE_Thread_Mutex, int>; -#elif defined (ACE_HAS_TEMPLATE_INSTANTIATION_PRAGMA) -#pragma instantiate ACE_TSS<Thr_ID> -#pragma instantiate ACE_Atomic_Op<ACE_Thread_Mutex, int> -#endif /* ACE_HAS_EXPLICIT_TEMPLATE_INSTANTIATION */ - -#endif /* ACE_HAS_PTHREADS || ACE_HAS_DCETHREADS || VXWORKS */ #endif /* ACE_HAS_THREADS */ diff --git a/performance-tests/Synch-Benchmarks/Benchmark.h b/performance-tests/Synch-Benchmarks/Benchmark.h index f76cd8eeee3..8aaa7a72528 100644 --- a/performance-tests/Synch-Benchmarks/Benchmark.h +++ b/performance-tests/Synch-Benchmarks/Benchmark.h @@ -6,44 +6,17 @@ #if !defined (ACE_BENCHMARK_H) #define ACE_BENCHMARK_H -#include "ace/Service_Config.h" -#include "ace/Synch.h" -#include "ace/Service_Types.h" +#include "Benchmark_Base.h" #if defined (ACE_HAS_THREADS) extern int buffer; extern ACE_Svc_Export int synch_count; -#if defined (ACE_HAS_PTHREADS) || defined (ACE_HAS_DCETHREADS) || defined (VXWORKS) - -typedef ACE_Atomic_Op<ACE_Thread_Mutex, int> MT_INT; - -class Thr_ID - // TITLE - // A simple class that provides a thread-specific value in order - // to compensate for POSIX Pthreads. - // - // DESCRIPTION - // Pthreads are too lame to have a sensible scalar values for the - // thread id (unlike Solaris threads). Therefore, we have to - // emulate this ourselves with this class (gag). +class ACE_Svc_Export Benchmark : public Benchmark_Base { -public: - Thr_ID (void); - int thr_id (void); - void thr_id (int); - -private: - int thr_id_; - static MT_INT thread_id_; -}; -#endif /* ACE_HAS_PTHREADS || ACE_HAS_DCETHREADS || VXWORKS */ - -class ACE_Svc_Export Benchmark : public ACE_Service_Object // TITLE // Base class for all the timing tests. -{ public: // = Hooks inherited from ACE_Service_Object. virtual int svc (void); @@ -52,9 +25,6 @@ public: virtual int fini (void); static void *svc_run (Benchmark *bp); - int thr_id (void); - // Returns our thread id; - // = Set/get flag that controls how the tests are shut down // gracefully. static void done (sig_atomic_t); @@ -63,11 +33,6 @@ public: protected: static sig_atomic_t done_; // Keeps track if we are finished or not. - -#if defined (ACE_HAS_PTHREADS) || defined (ACE_HAS_DCETHREADS) || defined (VXWORKS) - ACE_TSS <Thr_ID> id_; - // Keeps track of our "virtual" thread id... -#endif /* ACE_HAS_PTHREADS || ACE_HAS_DCETHREADS || VXWORKS */ }; #endif /* ACE_HAS_THREADS */ #endif /* ACE_BENCHMARK_H */ diff --git a/performance-tests/Synch-Benchmarks/Benchmark_Base.cpp b/performance-tests/Synch-Benchmarks/Benchmark_Base.cpp new file mode 100644 index 00000000000..c013a191eed --- /dev/null +++ b/performance-tests/Synch-Benchmarks/Benchmark_Base.cpp @@ -0,0 +1,63 @@ +// $Id$ + +#define ACE_BUILD_SVC_DLL +#include "Benchmark_Base.h" + +#if defined (ACE_HAS_THREADS) + +// Initialize the static variables. +/* static */ + +Benchmark_Base::Benchmark_Base (void) + : benchmark_type_ (Benchmark_Base::BENCHMARK_BASE) +{ +} + +int +Benchmark_Base::benchmark_type (void) +{ + return this->benchmark_type_; +} + +int +Benchmark_Base::thr_id (void) +{ +#if defined (ACE_HAS_PTHREADS) || defined (ACE_HAS_DCETHREADS) || defined (VXWORKS) + // This invokes the thread-specific storage smart pointer. + return this->id_->thr_id (); +#else + return ACE_Thread::self (); +#endif /* ACE_HAS_PTHREADS || ACE_HAS_DCETHREADS || VXWORKS */ +} + +#if defined (ACE_HAS_PTHREADS) || defined (ACE_HAS_DCETHREADS) || defined (VXWORKS) +/* static */ +MT_INT Thr_ID::thread_id_ (0); + +Thr_ID::Thr_ID (void) + : thr_id_ (++Thr_ID::thread_id_) +{ +} + +int +Thr_ID::thr_id (void) +{ + return this->thr_id_; +} + +void +Thr_ID::thr_id (int i) +{ + this->thr_id_ = i; +} + +#if defined (ACE_HAS_EXPLICIT_TEMPLATE_INSTANTIATION) +template class ACE_TSS<Thr_ID>; +template class ACE_Atomic_Op<ACE_Thread_Mutex, int>; +#elif defined (ACE_HAS_TEMPLATE_INSTANTIATION_PRAGMA) +#pragma instantiate ACE_TSS<Thr_ID> +#pragma instantiate ACE_Atomic_Op<ACE_Thread_Mutex, int> +#endif /* ACE_HAS_EXPLICIT_TEMPLATE_INSTANTIATION */ + +#endif /* ACE_HAS_PTHREADS || ACE_HAS_DCETHREADS || VXWORKS */ +#endif /* ACE_HAS_THREADS */ diff --git a/performance-tests/Synch-Benchmarks/Benchmark_Base.h b/performance-tests/Synch-Benchmarks/Benchmark_Base.h new file mode 100644 index 00000000000..c9d9dd6ca0d --- /dev/null +++ b/performance-tests/Synch-Benchmarks/Benchmark_Base.h @@ -0,0 +1,78 @@ +/* -*- C++ -*- */ +// $Id$ + +/* Defines the base class used to dynamically link in the benchmark tests */ + +#if !defined (ACE_BENCHMARK_BASE_H) +# define ACE_BENCHMARK_BASE_H + +# include "ace/Service_Config.h" +# include "ace/Synch.h" +# include "ace/Service_Types.h" + +# if defined (ACE_HAS_THREADS) + +# if defined (ACE_HAS_PTHREADS) || defined (ACE_HAS_DCETHREADS) || defined (VXWORKS) + +typedef ACE_Atomic_Op<ACE_Thread_Mutex, int> MT_INT; + +class Thr_ID + // TITLE + // A simple class that provides a thread-specific value in order + // to compensate for POSIX Pthreads. + // + // DESCRIPTION + // Pthreads are too lame to have a sensible scalar values for the + // thread id (unlike Solaris threads). Therefore, we have to + // emulate this ourselves with this class (gag). +{ +public: + Thr_ID (void); + int thr_id (void); + void thr_id (int); + +private: + int thr_id_; + static MT_INT thread_id_; +}; +# endif /* ACE_HAS_PTHREADS || ACE_HAS_DCETHREADS || VXWORKS */ + +class ACE_Svc_Export Benchmark_Base : public ACE_Service_Object +{ + // = TITLE + // Base class for all benchmarking objects. + // + // = DESCRIPTION + // This class is the base class for all benchmarking + // classes. Its major functionalities are to privide RTTI + // information and to define other common methods all + // benchmarking classes should support. +public: + + Benchmark_Base (void); + // Default ctor. + + enum { + BENCHMARK_BASE, + METHOD, + BASELINE, + PERFORMANCE + }; + + int benchmark_type (void); + // RTTI information of this module. + + int thr_id (void); + // Returns our thread id; + +protected: + int benchmark_type_; + // Store the RTTI info of this module. + +# if defined (ACE_HAS_PTHREADS) || defined (ACE_HAS_DCETHREADS) || defined (VXWORKS) + ACE_TSS <Thr_ID> id_; + // Keeps track of our "virtual" thread id... +# endif /* ACE_HAS_PTHREADS || ACE_HAS_DCETHREADS || VXWORKS */ +}; +# endif /* ACE_HAS_THREADS */ +#endif /* ACE_BENCHMARK_H */ diff --git a/performance-tests/Synch-Benchmarks/Makefile b/performance-tests/Synch-Benchmarks/Makefile index 366f33eb326..d9b16ab2f42 100644 --- a/performance-tests/Synch-Benchmarks/Makefile +++ b/performance-tests/Synch-Benchmarks/Makefile @@ -25,9 +25,10 @@ FILES = mutex_test \ pipe_thr_test \ pipe_proc_test \ Options \ - Benchmark + Benchmark \ + Benchmark_Base -LSRC = $(addsuffix .cpp,$(FILES)) +LSRC = $(addsuffix .cpp,$(FILES)) LOBJ = $(LSRC:%.cpp=$(VDIR)%.o) SHOBJ = $(addsuffix .so,$(FILES)) |