diff options
Diffstat (limited to 'performance-tests/Synch-Benchmarks/Synch_Lib')
4 files changed, 266 insertions, 0 deletions
diff --git a/performance-tests/Synch-Benchmarks/Synch_Lib/Benchmark_Base.cpp b/performance-tests/Synch-Benchmarks/Synch_Lib/Benchmark_Base.cpp new file mode 100644 index 00000000000..04c3fbc52d2 --- /dev/null +++ b/performance-tests/Synch-Benchmarks/Synch_Lib/Benchmark_Base.cpp @@ -0,0 +1,104 @@ +// $Id$ + +#define SYNCHLIB_BUILD_DLL +#include "Benchmark_Base.h" + +ACE_RCSID(Synch_Benchmarks, Benchmark_Base, "$Id$") + +#if defined (ACE_HAS_THREADS) + +// Initialize the static variables. +/* static */ + +Benchmark_Base::Benchmark_Base (int type) + : benchmark_type_ (type) +{ +} + +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 */ +} + +Benchmark_Method_Base::Benchmark_Method_Base (void) + : Benchmark_Base (Benchmark_Base::METHOD) +{ +} + +int +Benchmark_Method_Base::exec (ACE_Service_Repository_Iterator *sri) +{ + sri->advance (); + for (const ACE_Service_Type *sr; + sri->next (sr) != 0; + sri->advance ()) + { + // This would greatly benefit from RTTI typesafe downcasting... + const ACE_Service_Type_Impl *type = sr->type (); + const void *obj = type->object (); + ACE_Service_Object *so = (ACE_Service_Object *) obj; + Benchmark_Base *bp = (Benchmark_Base *) so; + + if (this->valid_test_object (bp)) + { + + ACE_DEBUG ((LM_DEBUG, "\nstarting up %s\n", sr->name ())); + + int notused = this->pre_run_test (bp) == 0 && this->run_test () == 0 && + this->post_run_test () == 0; + notused = notused; + } + else + return 0; + } + return 0; +} + +Benchmark_Performance_Test_Base::Benchmark_Performance_Test_Base (void) + : Benchmark_Base (Benchmark_Base::PERFORMANCE) +{ +} + +#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/Synch_Lib/Benchmark_Base.h b/performance-tests/Synch-Benchmarks/Synch_Lib/Benchmark_Base.h new file mode 100644 index 00000000000..7a43436f0f9 --- /dev/null +++ b/performance-tests/Synch-Benchmarks/Synch_Lib/Benchmark_Base.h @@ -0,0 +1,122 @@ +/* -*- C++ -*- */ +// $Id$ + +/* Defines the base class used to dynamically link in the benchmark tests */ + +#ifndef ACE_BENCHMARK_BASE_H +# define ACE_BENCHMARK_BASE_H + +# include "ace/Service_Config.h" + +#if !defined (ACE_LACKS_PRAGMA_ONCE) +# pragma once +#endif /* ACE_LACKS_PRAGMA_ONCE */ + +# include "ace/Service_Repository.h" +# include "ace/Synch.h" +# include "ace/Service_Types.h" +# include "export_mac.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 SYNCHLIB_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: + enum { + BENCHMARK_BASE, + METHOD, + BASELINE, + PERFORMANCE + }; + + int benchmark_type (void); + // RTTI information of this module. + + int thr_id (void); + // Returns our thread id; + +protected: + Benchmark_Base (int type = BENCHMARK_BASE); + // Default ctor. + + 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 */ +}; + +class SYNCHLIB_Export Benchmark_Method_Base : public Benchmark_Base +{ + // = TITLE + // This class identifies itself as Benmarking Method class. + // It defines a method as of how the test is setup and measured. +public: + int exec (ACE_Service_Repository_Iterator *sri); + // Run the test and advanced the service repository iterator + + virtual int pre_run_test (Benchmark_Base *bp) = 0; + // Before running the real test. Subclasses implement this method + // to dictate how the test is performed. + + virtual int run_test (void) = 0; + // Run the real test. Subclasses implement this method to + // dictate how the test is performed. + + virtual int post_run_test (void) = 0; + // After running the real test. Subclasses implement this method to + // dictate how the test is performed. + + virtual int valid_test_object (Benchmark_Base *) = 0; + // Check if we got a valid test to perform. + +protected: + Benchmark_Method_Base (void); +}; + +class SYNCHLIB_Export Benchmark_Performance_Test_Base : public Benchmark_Base +{ + // = TITLE + // This class identifies itself as Benmarking Performance Test class. +protected: + Benchmark_Performance_Test_Base (void); +}; + + +# endif /* ACE_HAS_THREADS */ +#endif /* ACE_BENCHMARK_BASE_H */ diff --git a/performance-tests/Synch-Benchmarks/Synch_Lib/README b/performance-tests/Synch-Benchmarks/Synch_Lib/README new file mode 100644 index 00000000000..f17fe39234a --- /dev/null +++ b/performance-tests/Synch-Benchmarks/Synch_Lib/README @@ -0,0 +1,4 @@ +This subdirectory contains a library that defines the interface used +by all benchmarking modules. The library is required by all modules +and the synch_driver. If you want to develop your own benchmarking +module, this directory provides a starting point. diff --git a/performance-tests/Synch-Benchmarks/Synch_Lib/export_mac.h b/performance-tests/Synch-Benchmarks/Synch_Lib/export_mac.h new file mode 100644 index 00000000000..9ccc20f399d --- /dev/null +++ b/performance-tests/Synch-Benchmarks/Synch_Lib/export_mac.h @@ -0,0 +1,36 @@ +// -*- C++ -*- +// $Id$ +// Definition for Win32 Export directives. +// This file is generated automatically by +// ${ACE_ROOT}/GenExportH.BAT +// ------------------------------ +#if !defined (SYNCHLIB_EXPORT_H) +#define SYNCHLIB_EXPORT_H + +#include "ace/OS.h" + +#if !defined (SYNCHLIB_HAS_DLL) +#define SYNCHLIB_HAS_DLL 1 +#endif /* !SYNCHLIB_HAS_DLL */ + +#if defined (SYNCHLIB_HAS_DLL) +# if (SYNCHLIB_HAS_DLL == 1) +# if defined (SYNCHLIB_BUILD_DLL) +# define SYNCHLIB_Export ACE_Proper_Export_Flag +# define SYNCHLIB_SINGLETON_DECLARATION(T) ACE_EXPORT_SINGLETON_DECLARATION (T) +# else +# define SYNCHLIB_Export ACE_Proper_Import_Flag +# define SYNCHLIB_SINGLETON_DECLARATION(T) ACE_IMPORT_SINGLETON_DECLARATION (T) +# endif /* SYNCHLIB_BUILD_DLL */ +# else +# define SYNCHLIB_Export +# define SYNCHLIB_SINGLETON_DECLARATION(T) +# endif /* ! SYNCHLIB_HAS_DLL == 1 */ +#else +# define SYNCHLIB_Export +# define SYNCHLIB_SINGLETON_DECLARATION(T) +#endif /* SYNCHLIB_HAS_DLL */ + +#endif /* SYNCHLIB_EXPORT_H */ + +// End of auto generated file. |