summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorirfan <irfan@ae88bc3d-4319-0410-8dbf-d08b4c9d3795>1998-05-26 05:37:58 +0000
committerirfan <irfan@ae88bc3d-4319-0410-8dbf-d08b4c9d3795>1998-05-26 05:37:58 +0000
commit03140049c3719e880ead0521808e17f4182f52da (patch)
tree4a776d9821c2e443633d78d8a4ebf20e02cebd30
parent508b9dfcdc15f1e16626a040cb3edd8ea911c6a5 (diff)
downloadATCD-03140049c3719e880ead0521808e17f4182f52da.tar.gz
*** empty log message ***
-rw-r--r--ChangeLog-98b9
-rw-r--r--ace/Timeprobe.cpp62
-rw-r--r--ace/Timeprobe.h68
3 files changed, 107 insertions, 32 deletions
diff --git a/ChangeLog-98b b/ChangeLog-98b
index ebcfc3d9f1c..e1dcfe9ad88 100644
--- a/ChangeLog-98b
+++ b/ChangeLog-98b
@@ -1,3 +1,12 @@
+Tue May 26 00:35:49 1998 Irfan Pyarali <irfan@cs.wustl.edu>
+
+ * ace/Timeprobe: Added the ability to have multiple event tables
+ for time probes. Multiple maps can be used to chunk up the time
+ probes. Each one can be added by calling event_descriptions().
+ Different tables are used internally by consulting the
+ minimum_id for each table. It is up to the user to make sure
+ that multiple tables do not share the same event id range.
+
Sat Apr 18 01:28:36 1998 Irfan Pyarali <irfan@cs.wustl.edu>
* ace/Timeprobe.h (class ACE_Timeprobe): Changed ACE_Timeprobe to
diff --git a/ace/Timeprobe.cpp b/ace/Timeprobe.cpp
index 6f6d451b9bc..940e7a9f1e8 100644
--- a/ace/Timeprobe.cpp
+++ b/ace/Timeprobe.cpp
@@ -29,7 +29,7 @@ ACE_Timeprobe<ACE_LOCK>::ACE_Timeprobe (u_long size,
template <class ACE_LOCK>
ACE_Timeprobe<ACE_LOCK>::~ACE_Timeprobe (void)
{
- for (int i = 0; i < this->max_size_; i++)
+ for (u_long i = 0; i < this->max_size_; i++)
this->timeprobes_[i].timeprobe_t::~timeprobe_t ();
this->allocator_->free (this->timeprobes_);
@@ -74,7 +74,18 @@ ACE_Timeprobe<ACE_LOCK>::reset (void)
}
template <class ACE_LOCK> void
-ACE_Timeprobe<ACE_LOCK>::print_times (const char *event_descriptions[]) const
+ACE_Timeprobe<ACE_LOCK>::event_descriptions (const char **descriptions,
+ u_long minimum_id)
+{
+ Event_Descriptions events;
+ events.descriptions_ = descriptions;
+ events.minimum_id_ = minimum_id;
+
+ this->event_descriptions_.insert (events);
+}
+
+template <class ACE_LOCK> void
+ACE_Timeprobe<ACE_LOCK>::print_times (void)
{
ACE_DEBUG ((LM_DEBUG,
"\nACE_Timeprobe; %d timestamps were recorded:\n",
@@ -89,36 +100,47 @@ ACE_Timeprobe<ACE_LOCK>::print_times (const char *event_descriptions[]) const
"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,
"%-50.50s %8.8x %13.13s\n",
- description,
+ this->find_description (0),
this->timeprobes_[0].thread_,
"START"));
- for (u_int i = 1; i < this->current_size_; i++)
+ for (u_long i = 1; i < this->current_size_; i++)
{
ACE_hrtime_t time_difference =
this->timeprobes_[i].time_ - this->timeprobes_[i-1].time_;
- float elapsed_time_in_micro_seconds =
- (float) time_difference / ACE_High_Res_Timer::global_scale_factor ();
+ ACE_UINT32 elapsed_time_in_micro_seconds =
+ (ACE_UINT32) (time_difference / ACE_High_Res_Timer::global_scale_factor ());
- 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,
- "%-50.50s %8.8x %13.3f\n",
- description,
+ "%-50.50s %8.8x %13u\n",
+ this->find_description (i),
this->timeprobes_[i].thread_,
- elapsed_time_in_micro_seconds));
+ (unsigned int) elapsed_time_in_micro_seconds));
+ }
+}
+
+template <class ACE_LOCK> const char *
+ACE_Timeprobe<ACE_LOCK>::find_description (u_long i)
+{
+ if (this->timeprobes_[i].event_type_ == timeprobe_t::STRING)
+ return this->timeprobes_[i].event_.event_description_;
+ else
+ {
+ EVENT_DESCRIPTIONS::iterator iterator = this->event_descriptions_.begin ();
+ for (u_long j = 0;
+ j < this->event_descriptions_.size () - 1;
+ iterator++, j++)
+ {
+ EVENT_DESCRIPTIONS::iterator next_event_descriptions = iterator;
+ next_event_descriptions++;
+
+ if (this->timeprobes_[i].event_.event_number_ < (*next_event_descriptions).minimum_id_)
+ break;
+ }
+ return (*iterator).descriptions_[this->timeprobes_[i].event_.event_number_ - (*iterator).minimum_id_];
}
}
diff --git a/ace/Timeprobe.h b/ace/Timeprobe.h
index 72123a093d2..60404ac7cde 100644
--- a/ace/Timeprobe.h
+++ b/ace/Timeprobe.h
@@ -30,13 +30,19 @@ class ACE_Timeprobe
//
// 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.
+ // descriptions in any of your time probes, you must have
+ // provided 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.
//
+ // Multiple maps can also be used to chunk up the time probes.
+ // Each one can be added by calling event_descriptions().
+ // Different tables are used internally by consulting the
+ // minimum_id for each table. It is up to the user to make sure
+ // that multiple tables do not share the same event id range.
public:
enum
@@ -59,18 +65,51 @@ public:
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 event_descriptions (const char **descriptions,
+ u_long minimum_id);
+ // Record event descriptions.
+
+ void print_times (void);
+ // Print the time probes.
void reset (void);
// Reset the slots. All old time probes will be lost.
protected:
+ typedef ACE_Timeprobe<ACE_LOCK> SELF;
+ // Self
+
+ // = Event Descriptions
+ struct Event_Descriptions
+ {
+ const char **descriptions_;
+ // Event descriptions
+
+ u_long minimum_id_;
+ // Minimum id of this description set
+
+ int operator== (const Event_Descriptions &rhs) const
+ {
+ return
+ this->minimum_id_ == rhs.minimum_id_ &&
+ this->descriptions_ == rhs.descriptions_;
+ }
+ // Comparison
+ };
+
+ typedef ACE_Unbounded_Set<Event_Descriptions> EVENT_DESCRIPTIONS;
+ // We can hold multiple event description tables
+
+ EVENT_DESCRIPTIONS event_descriptions_;
+ // Event Descriptions
+
ACE_Timeprobe (const ACE_Timeprobe &);
// Not implemented.
+ const char *find_description (u_long i);
+ // Find description of event <i>
+
// = Time probe record
struct timeprobe_t
{
@@ -120,6 +159,11 @@ protected:
template <class Timeprobe>
class ACE_Function_Timeprobe
{
+ // = TITLE
+ //
+ // Auto pointer like time probes. It will record <event> on
+ // construction and <event + 1> on destruction.
+ //
public:
ACE_Function_Timeprobe (Timeprobe &timeprobe,
u_long event);
@@ -177,7 +221,7 @@ typedef ACE_Singleton<ACE_TIMEPROBE_WITH_LOCKING, ACE_Thread_Mutex> ACE_TIMEPROB
# 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)
+# define ACE_TIMEPROBE_EVENT_DESCRIPTIONS(descriptions, minimum_id) ACE_TIMEPROBE_SINGLETON::instance ()->event_descriptions (descriptions, minimum_id)
# define ACE_FUNCTION_TIMEPROBE(X) ACE_Function_Timeprobe<ACE_TIMEPROBE_WITH_LOCKING> function_timeprobe (*ACE_TIMEPROBE_SINGLETON::instance (), X)
#else /* ACE_ENABLE_TIMEPROBES */
@@ -185,8 +229,8 @@ typedef ACE_Singleton<ACE_TIMEPROBE_WITH_LOCKING, ACE_Thread_Mutex> ACE_TIMEPROB
# define ACE_TIMEPROBE_RESET
# define ACE_TIMEPROBE(id)
# define ACE_TIMEPROBE_PRINT
-# define ACE_TIMEPROBE_PRINT_USING_TABLE(table)
-# define ACE_FUNCTION_TIMEPROBE(X)
+# define ACE_TIMEPROBE_EVENT_DESCRIPTIONS(descriptions, minimum_id)
+# define ACE_FUNCTION_TIMEPROBE(X)
#endif /* ACE_ENABLE_TIMEPROBES */