diff options
author | irfan <irfan@ae88bc3d-4319-0410-8dbf-d08b4c9d3795> | 1998-04-16 09:19:18 +0000 |
---|---|---|
committer | irfan <irfan@ae88bc3d-4319-0410-8dbf-d08b4c9d3795> | 1998-04-16 09:19:18 +0000 |
commit | e554ce13cf6ddaaf1bfff419bcbe4b2264e1c004 (patch) | |
tree | 0120b1803215e8f4efd71ce02dc609ff51d1eb89 | |
parent | 27ca79a67d0632d12e366d5102b393960b1686cd (diff) | |
download | ATCD-e554ce13cf6ddaaf1bfff419bcbe4b2264e1c004.tar.gz |
*** empty log message ***
-rw-r--r-- | ChangeLog-98a | 26 | ||||
-rw-r--r-- | TAO/ChangeLog-98c | 3 | ||||
-rw-r--r-- | TAO/examples/Simulator/DOVEMIB/DOVEMIB.cpp | 2 | ||||
-rw-r--r-- | TAO/examples/Simulator/Event_Supplier/Event_Con.cpp | 2 | ||||
-rw-r--r-- | TAO/examples/Simulator/Event_Supplier/Event_Sup.cpp | 2 | ||||
-rw-r--r-- | TAO/orbsvcs/orbsvcs/Event/Dispatching_Modules.h | 2 | ||||
-rw-r--r-- | TAO/orbsvcs/orbsvcs/Event/Event_Channel.h | 2 | ||||
-rw-r--r-- | TAO/orbsvcs/orbsvcs/Event/ReactorTask.cpp | 2 | ||||
-rw-r--r-- | TAO/orbsvcs/tests/EC_Multiple/EC_Multiple.cpp | 2 | ||||
-rw-r--r-- | TAO/orbsvcs/tests/Event_Latency/Event_Latency.cpp | 2 | ||||
-rw-r--r-- | TAO/tao/GIOP.cpp | 1 | ||||
-rw-r--r-- | TAO/tao/ORB.cpp | 2 | ||||
-rw-r--r-- | ace/Makefile | 1 | ||||
-rw-r--r-- | ace/Timeprobe.cpp | 122 | ||||
-rw-r--r-- | ace/Timeprobe.h | 176 | ||||
-rw-r--r-- | ace/Timeprobe.i | 2 |
16 files changed, 339 insertions, 10 deletions
diff --git a/ChangeLog-98a b/ChangeLog-98a index f0ebb07ad59..5b016dd33c2 100644 --- a/ChangeLog-98a +++ b/ChangeLog-98a @@ -1,3 +1,29 @@ +Thu Apr 16 04:14:53 1998 Irfan Pyarali <irfan@cs.wustl.edu> + + * ace/Timeprobe: + + This class is used to instrument code. This is accomplished by + inserting time probes at different location in the code. + ACE_Timeprobe then measures the time difference between two time + probes. + + This class provides a lightweight implementation for measuring + the time required to execute code between two time probes. When + a time probe executes, it records the time, the id of the + calling thread, and an event description. The event description + can either be an unsigned long or a string (char *). If string + are used, care must be taken cause only pointer copies are done + and the string data is *not* copied. + + The recorded time probes can then be printed by calling + print_times(). If you have used unsigned longs as event + descriptions in any of your time probes, you must provide an + event description table that maps the unsigned longs to readable + strings. This map is a simple array of strings, and the event + number is used as the index into the array when looking for the + event description. If you have only used strings for the event + description, this map is not necessary. + Wed Apr 15 23:01:08 1998 Nanbor Wang <nanbor@cs.wustl.edu> * ace/Thread_Manager.cpp (exit): Don't delete the ACE_Thread_Exit diff --git a/TAO/ChangeLog-98c b/TAO/ChangeLog-98c index 40b190b67bb..a86fabf49af 100644 --- a/TAO/ChangeLog-98c +++ b/TAO/ChangeLog-98c @@ -1,5 +1,8 @@ Thu Apr 16 01:25:18 1998 Irfan Pyarali <irfan@cs.wustl.edu> + * TAO: Change the use of time probes. The new ACE scheme is now + used. + * tao/poa.idl: Fixed the idl file. * tao/PolicyS.cpp (_tao_collocated_Policy): _tao_collocated_Policy diff --git a/TAO/examples/Simulator/DOVEMIB/DOVEMIB.cpp b/TAO/examples/Simulator/DOVEMIB/DOVEMIB.cpp index cab75b1171d..0d4649c5557 100644 --- a/TAO/examples/Simulator/DOVEMIB/DOVEMIB.cpp +++ b/TAO/examples/Simulator/DOVEMIB/DOVEMIB.cpp @@ -27,7 +27,7 @@ #include "ace/Get_Opt.h" #include "ace/Sched_Params.h" #include "ace/Profile_Timer.h" -#include "tao/Timeprobe.h" +#include "ace/Timeprobe.h" #include "orbsvcs/Event_Utilities.h" #include "orbsvcs/Event_Service_Constants.h" #include "orbsvcs/Scheduler_Factory.h" diff --git a/TAO/examples/Simulator/Event_Supplier/Event_Con.cpp b/TAO/examples/Simulator/Event_Supplier/Event_Con.cpp index 1c46bdc512f..cf594d66af4 100644 --- a/TAO/examples/Simulator/Event_Supplier/Event_Con.cpp +++ b/TAO/examples/Simulator/Event_Supplier/Event_Con.cpp @@ -27,7 +27,7 @@ #include "ace/Get_Opt.h" #include "ace/Sched_Params.h" #include "ace/Profile_Timer.h" -#include "tao/Timeprobe.h" +#include "ace/Timeprobe.h" #include "orbsvcs/Event_Utilities.h" #include "orbsvcs/Event_Service_Constants.h" #include "orbsvcs/Scheduler_Factory.h" diff --git a/TAO/examples/Simulator/Event_Supplier/Event_Sup.cpp b/TAO/examples/Simulator/Event_Supplier/Event_Sup.cpp index 36adeec054b..cb705110b16 100644 --- a/TAO/examples/Simulator/Event_Supplier/Event_Sup.cpp +++ b/TAO/examples/Simulator/Event_Supplier/Event_Sup.cpp @@ -23,7 +23,7 @@ #include "ace/Sched_Params.h" #include "ace/Profile_Timer.h" #include "ace/OS.h" -#include "tao/Timeprobe.h" +#include "ace/Timeprobe.h" #include "tao/corba.h" #include "orbsvcs/Event_Utilities.h" #include "orbsvcs/Event_Service_Constants.h" diff --git a/TAO/orbsvcs/orbsvcs/Event/Dispatching_Modules.h b/TAO/orbsvcs/orbsvcs/Event/Dispatching_Modules.h index 3ec2c40da06..4706500f7cb 100644 --- a/TAO/orbsvcs/orbsvcs/Event/Dispatching_Modules.h +++ b/TAO/orbsvcs/orbsvcs/Event/Dispatching_Modules.h @@ -23,7 +23,7 @@ #ifndef ACE_DISPATCHING_MODULES_H #define ACE_DISPATCHING_MODULES_H -#include "tao/Timeprobe.h" +#include "ace/Timeprobe.h" #include "ReactorTask.h" #include "Event_Channel.h" diff --git a/TAO/orbsvcs/orbsvcs/Event/Event_Channel.h b/TAO/orbsvcs/orbsvcs/Event/Event_Channel.h index 9e2e458a01a..00811689e9d 100644 --- a/TAO/orbsvcs/orbsvcs/Event/Event_Channel.h +++ b/TAO/orbsvcs/orbsvcs/Event/Event_Channel.h @@ -33,7 +33,7 @@ #include "ace/Containers.h" #include "ace/Map_Manager.h" -#include "tao/Timeprobe.h" +#include "ace/Timeprobe.h" #include "Local_ESTypes.h" #include "CORBA_Utils_T.h" #include "Task_Manager.h" diff --git a/TAO/orbsvcs/orbsvcs/Event/ReactorTask.cpp b/TAO/orbsvcs/orbsvcs/Event/ReactorTask.cpp index 0f7e7bf38e1..5e2d1fb4ddf 100644 --- a/TAO/orbsvcs/orbsvcs/Event/ReactorTask.cpp +++ b/TAO/orbsvcs/orbsvcs/Event/ReactorTask.cpp @@ -1,7 +1,7 @@ // $Id$ #include "ace/High_Res_Timer.h" -#include "tao/Timeprobe.h" +#include "ace/Timeprobe.h" #include "orbsvcs/Scheduler_Factory.h" #include "ReactorTask.h" diff --git a/TAO/orbsvcs/tests/EC_Multiple/EC_Multiple.cpp b/TAO/orbsvcs/tests/EC_Multiple/EC_Multiple.cpp index 132b787cdf6..07a9644857e 100644 --- a/TAO/orbsvcs/tests/EC_Multiple/EC_Multiple.cpp +++ b/TAO/orbsvcs/tests/EC_Multiple/EC_Multiple.cpp @@ -4,7 +4,7 @@ #include "ace/Get_Opt.h" -#include "tao/Timeprobe.h" +#include "ace/Timeprobe.h" #include "orbsvcs/Event_Utilities.h" #include "orbsvcs/Event_Service_Constants.h" #include "orbsvcs/Scheduler_Factory.h" diff --git a/TAO/orbsvcs/tests/Event_Latency/Event_Latency.cpp b/TAO/orbsvcs/tests/Event_Latency/Event_Latency.cpp index 94d0ae3670d..1bcfe17a05a 100644 --- a/TAO/orbsvcs/tests/Event_Latency/Event_Latency.cpp +++ b/TAO/orbsvcs/tests/Event_Latency/Event_Latency.cpp @@ -9,7 +9,7 @@ #include "ace/Sched_Params.h" #include "ace/Profile_Timer.h" -#include "tao/Timeprobe.h" +#include "ace/Timeprobe.h" #include "orbsvcs/Event_Utilities.h" #include "orbsvcs/Event_Service_Constants.h" #include "orbsvcs/Scheduler_Factory.h" diff --git a/TAO/tao/GIOP.cpp b/TAO/tao/GIOP.cpp index 0a0e35d58b9..b897c9a06b0 100644 --- a/TAO/tao/GIOP.cpp +++ b/TAO/tao/GIOP.cpp @@ -179,7 +179,6 @@ TAO_GIOP::send_request (TAO_SVC_HANDLER *handler, #endif /* DEBUG */ } ACE_TIMEPROBE (TAO_GIOP_SEND_REQUEST_FAIL); - ACE_TIMEPROBE (); return CORBA::B_TRUE; } diff --git a/TAO/tao/ORB.cpp b/TAO/tao/ORB.cpp index 61cdbf63250..37cf9c7003d 100644 --- a/TAO/tao/ORB.cpp +++ b/TAO/tao/ORB.cpp @@ -185,7 +185,7 @@ CORBA_ORB::run (ACE_Time_Value *tv) while (this->should_shutdown_ == 0) { - ACE_TIMEPROBE (TAO_CORBA_ORB_RUN); + ACE_TIMEPROBE (TAO_CORBA_ORB_RUN_START); switch (r->handle_events (tv)) { case 0: // Timed out, so we return to caller. diff --git a/ace/Makefile b/ace/Makefile index 34ca3341232..b4650dea604 100644 --- a/ace/Makefile +++ b/ace/Makefile @@ -167,6 +167,7 @@ TEMPLATE_FILES = \ Svc_Handler \ Synch_T \ Task_T \ + Timeprobe \ Timer_Hash_T \ Timer_Heap_T \ Timer_List_T \ diff --git a/ace/Timeprobe.cpp b/ace/Timeprobe.cpp new file mode 100644 index 00000000000..ef78a159677 --- /dev/null +++ b/ace/Timeprobe.cpp @@ -0,0 +1,122 @@ +// $Id$ + +#if !defined (ACE_TIMEPROBE_C) +#define ACE_TIMEPROBE_C + +#include "ace/Timeprobe.h" + +#if defined (ACE_ENABLE_TIMEPROBES) + +#if !defined (__ACE_INLINE__) +#include "ace/Timeprobe.i" +#endif /* __ACE_INLINE__ */ + +template <class ACE_LOCK> +ACE_Timeprobe<ACE_LOCK>::ACE_Timeprobe (u_long size, + ACE_Allocator *alloc) + : allocator_ (alloc != 0 ? alloc : ACE_Allocator::instance ()), + timeprobes_ (0), + lock_ (), + max_size_ (size), + current_size_ (0) +{ + void *space = this->allocator_->malloc ((sizeof timeprobe_t) * this->max_size_); + this->timeprobes_ = new ((timeprobe_t *) space) timeprobe_t[this->max_size_]; +} + +template <class ACE_LOCK> +ACE_Timeprobe<ACE_LOCK>::~ACE_Timeprobe (void) +{ + for (int i = 0; i < this->max_size_; i++) + this->timeprobes_[i].timeprobe_t::~timeprobe_t (); + + this->allocator_->free (this->timeprobes_); +} + +template <class ACE_LOCK> void +ACE_Timeprobe<ACE_LOCK>::timeprobe (u_long event) +{ + ACE_GUARD (ACE_LOCK, ace_mon, this->lock_); + + ACE_ASSERT (this->current_size_ < this->max_size_); + + this->timeprobes_[this->current_size_].event_.event_number_ = event; + this->timeprobes_[this->current_size_].event_type_ = timeprobe_t::NUMBER; + this->timeprobes_[this->current_size_].time_ = ACE_OS::gettimeofday (); + this->timeprobes_[this->current_size_].thread_ = ACE_OS::thr_self (); + + this->current_size_++; +} + +template <class ACE_LOCK> void +ACE_Timeprobe<ACE_LOCK>::timeprobe (const char *event) +{ + ACE_GUARD (ACE_LOCK, ace_mon, this->lock_); + + ACE_ASSERT (this->current_size_ < this->max_size_); + + this->timeprobes_[this->current_size_].event_.event_description_ = event; + this->timeprobes_[this->current_size_].event_type_ = timeprobe_t::STRING; + this->timeprobes_[this->current_size_].time_ = ACE_OS::gettimeofday (); + this->timeprobes_[this->current_size_].thread_ = ACE_OS::thr_self (); + + this->current_size_++; +} + +template <class ACE_LOCK> void +ACE_Timeprobe<ACE_LOCK>::reset (void) +{ + ACE_GUARD (ACE_LOCK, ace_mon, this->lock_); + + this->current_size_ = 0; +} + +template <class ACE_LOCK> void +ACE_Timeprobe<ACE_LOCK>::print_times (const char *event_descriptions[]) const +{ + ACE_DEBUG ((LM_DEBUG, + "\nACE_Timeprobe; %d timestamps were recorded:\n", + this->current_size_)); + + if (this->current_size_ == 0) + return; + + ACE_DEBUG ((LM_DEBUG, + "\n%-50.50s %8.8s %10.10s\n\n", + "Event", + "thread", + "usec")); + + const char *description = 0; + if (this->timeprobes_[0].event_type_ == timeprobe_t::STRING) + description = this->timeprobes_[0].event_.event_description_; + else + description = event_descriptions[this->timeprobes_[0].event_.event_number_]; + + ACE_DEBUG ((LM_DEBUG, + "%-50s %8.8x %10.10s\n", + description, + this->timeprobes_[0].thread_, + "START")); + + for (u_int i = 1; i < this->current_size_; i++) + { + ACE_Time_Value elapsed = + this->timeprobes_[i].time_ - this->timeprobes_[i-1].time_; + + if (this->timeprobes_[i].event_type_ == timeprobe_t::STRING) + description = this->timeprobes_[i].event_.event_description_; + else + description = event_descriptions[this->timeprobes_[i].event_.event_number_]; + + ACE_DEBUG ((LM_DEBUG, + "%-50s %8.8x %10.3d\n", + description, + this->timeprobes_[i].thread_, + elapsed.msec () * 1000)); + } +} + +#endif /* ACE_ENABLE_TIMEPROBES */ + +#endif /* ACE_TIMEPROBE_C */ diff --git a/ace/Timeprobe.h b/ace/Timeprobe.h new file mode 100644 index 00000000000..f3204375902 --- /dev/null +++ b/ace/Timeprobe.h @@ -0,0 +1,176 @@ +// $Id$ + +#if !defined (ACE_TIMEPROBE_H) +#define ACE_TIMEPROBE_H + +// This class is compiled only when ACE_COMPILE_TIMEPROBES is defined +#if defined (ACE_COMPILE_TIMEPROBES) + +#include "ace/Malloc.h" + +template <class ACE_LOCK> +class ACE_Timeprobe +{ + // = TITLE + // + // This class is used to instrument code. This is accomplished + // by inserting time probes at different location in the code. + // ACE_Timeprobe then measures the time difference between two + // time probes. + // + // = DESCRIPTION + // + // This class provides a lightweight implementation for + // measuring the time required to execute code between two time + // probes. When a time probe executes, it records the time, the + // id of the calling thread, and an event description. The + // event description can either be an unsigned long or a string + // (char *). If string are used, care must be taken cause only + // pointer copies are done and the string data is *not* copied. + // + // The recorded time probes can then be printed by calling + // print_times(). If you have used unsigned longs as event + // descriptions in any of your time probes, you must provide an + // event description table that maps the unsigned longs to + // readable strings. This map is a simple array of strings, and + // the event number is used as the index into the array when + // looking for the event description. If you have only used + // strings for the event description, this map is not necessary. + // +public: + + enum + { + ACE_DEFAULT_TABLE_SIZE = 4 * 1024 + // Default size of the slots in Timeprobe + }; + + ACE_Timeprobe (u_long size = ACE_DEFAULT_TABLE_SIZE, + ACE_Allocator *alloc = 0); + // Create Timeprobes with <size> slots, using <alloc> for the + // allocator. + + ~ACE_Timeprobe (void); + // Destructor + + void timeprobe (u_long event); + // Record a time. <event> is used to describe this time probe. + + void timeprobe (const char *id); + // Record a time. <id> is used to describe this time probe. + + void print_times (const char *event_description[] = 0) const; + // Print the time probes. Use <event_description> as a map for + // converting unsigned long events to strings. + + void reset (void); + // Reset the slots. All old time probes will be lost. + +protected: + + ACE_Timeprobe (const ACE_Timeprobe &); + // Not implemented. + + // = Time probe record + struct timeprobe_t + { + union event + { + u_long event_number_; + const char *event_description_; + }; + // Events are record as strings or numbers + + enum event_type + { + NUMBER, + STRING + }; + // Type of event + + event event_; + // Event + + event_type event_type_; + // Event type + + ACE_Time_Value time_; + // Timestamp + + ACE_thread_t thread_; + // Id of thread posting the time probe + }; + + timeprobe_t *timeprobes_; + // Time probe slots + + ACE_Allocator *allocator_; + // Pointer to a memory allocator. + + ACE_LOCK lock_; + // Synchronization variable. + + u_long max_size_; + // Max size of timestamp table + + u_long current_size_; + // Current size of timestamp table +}; + + +#if defined (__ACE_INLINE__) +#include "ace/Timeprobe.i" +#endif /* __ACE_INLINE__ */ + +#if defined (ACE_TEMPLATES_REQUIRE_SOURCE) +#include "ace/Timeprobe.cpp" +#endif /* ACE_TEMPLATES_REQUIRE_SOURCE */ + +#if defined (ACE_TEMPLATES_REQUIRE_PRAGMA) +#pragma implementation ("Timeprobe.cpp") +#endif /* ACE_TEMPLATES_REQUIRE_PRAGMA */ + +#include "ace/Synch.h" +#include "ace/Singleton.h" + +// If ACE_MT_TIMEPROBES is defined, use a Thread_Mutex to lock the +// internal state of ACE_Timerprobe. This allows multiple threads to +// use the same ACE_Timerprobe. +# if defined (ACE_MT_TIMEPROBES) +typedef ACE_Timeprobe<ACE_Thread_Mutex> ACE_TIMEPROBE_WITH_LOCKING; +# else /* ACE_MT_TIMEPROBES */ +typedef ACE_Timeprobe<ACE_Null_Mutex> ACE_TIMEPROBE_WITH_LOCKING; +# endif /* ACE_MT_TIMEPROBES */ + +// If ACE_TSS_TIMEPROBES is defined, store the ACE_Timeprobe singleton +// in thread specific storage. This allows multiple threads to use +// their own instance of ACE_Timerprobe, without interfering with each +// other. +# if defined (ACE_TSS_TIMEPROBES) +typedef ACE_TSS_Singleton<ACE_TIMEPROBE_WITH_LOCKING, ACE_Null_Mutex> ACE_TIMEPROBE_SINGLETON; +# else /* ACE_TSS_TIMEPROBES */ +typedef ACE_Singleton<ACE_TIMEPROBE_WITH_LOCKING, ACE_Thread_Mutex> ACE_TIMEPROBE_SINGLETON; +# endif /* ACE_TSS_TIMEPROBES */ + +#endif /* ACE_COMPILE_TIMEPROBES */ + +// If ACE_ENABLE_TIMEPROBES is defined, the macros below will +// work. Otherwise, they just vanish. Using this macro, you can +// control which files/libraries are probed. +#if defined (ACE_ENABLE_TIMEPROBES) + +# define ACE_TIMEPROBE_RESET ACE_TIMEPROBE_SINGLETON::instance ()->reset () +# define ACE_TIMEPROBE(id) ACE_TIMEPROBE_SINGLETON::instance ()->timeprobe (id) +# define ACE_TIMEPROBE_PRINT ACE_TIMEPROBE_SINGLETON::instance ()->print_times () +# define ACE_TIMEPROBE_PRINT_USING_TABLE(table) ACE_TIMEPROBE_SINGLETON::instance ()->print_times (table) + +#else /* ACE_ENABLE_TIMEPROBES */ + +# define ACE_TIMEPROBE_RESET +# define ACE_TIMEPROBE(id) +# define ACE_TIMEPROBE_PRINT +# define ACE_TIMEPROBE_PRINT_USING_TABLE(table) + +#endif /* ACE_ENABLE_TIMEPROBES */ + +#endif /* ACE_TIMEPROBE_H */ diff --git a/ace/Timeprobe.i b/ace/Timeprobe.i new file mode 100644 index 00000000000..74e88caa0c5 --- /dev/null +++ b/ace/Timeprobe.i @@ -0,0 +1,2 @@ +// $Id$ + |