~ubuntu-branches/ubuntu/breezy/ace/breezy

« back to all changes in this revision

Viewing changes to ace/Timeprobe_T.h

  • Committer: Bazaar Package Importer
  • Author(s): Adam Conrad, Benjamin Montgomery, Adam Conrad
  • Date: 2005-09-18 22:51:38 UTC
  • mfrom: (1.2.1 upstream) (2.1.1 sarge) (0.1.2 woody)
  • Revision ID: james.westby@ubuntu.com-20050918225138-seav22q6fyylb536
Tags: 5.4.7-3ubuntu1
[ Benjamin Montgomery ]
* Added a patch for amd64 and powerpc that disables the compiler
  option -fvisibility-inlines-hidden

[ Adam Conrad ]
* Added DPATCH_OPTION_CPP=1 to debian/patches/00options to make
  Benjamin's above changes work correctly with dpatch.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
/* -*- C++ -*- */
2
 
 
3
 
//=============================================================================
4
 
/**
5
 
 *  @file    Timeprobe_T.h
6
 
 *
7
 
 *  Timeprobe_T.h,v 4.24 2003/11/01 11:15:18 dhinton Exp
8
 
 *
9
 
 *  @author Irfan Pyarali
10
 
 */
11
 
//=============================================================================
12
 
 
13
 
 
14
 
#ifndef ACE_TIMEPROBE_T_H
15
 
#define ACE_TIMEPROBE_T_H
16
 
#include /**/ "ace/pre.h"
17
 
 
18
 
#include "ace/config-all.h"
19
 
 
20
 
#if !defined (ACE_LACKS_PRAGMA_ONCE)
21
 
# pragma once
22
 
#endif /* ACE_LACKS_PRAGMA_ONCE */
23
 
 
24
 
#if defined (ACE_COMPILE_TIMEPROBES)
25
 
 
26
 
#include "ace/Unbounded_Set.h"
27
 
 
28
 
/**
29
 
 * @class ACE_Timeprobe
30
 
 *
31
 
 * @brief This class is used to instrument code.  This is accomplished
32
 
 * by inserting time probes at different location in the code.
33
 
 * ACE_Timeprobe then measures the time difference between two
34
 
 * time probes.
35
 
 *
36
 
 * This class provides a lightweight implementation for
37
 
 * measuring the time required to execute code between two time
38
 
 * probes.  When a time probe executes, it records the time, the
39
 
 * id of the calling thread, and an event description.  The
40
 
 * event description can either be an unsigned long or a string
41
 
 * (char *). If string are used, care must be taken cause only
42
 
 * pointer copies are done and the string data is *not* copied.
43
 
 * The recorded time probes can then be printed by calling
44
 
 * <print_times>.  If you have used unsigned longs as event
45
 
 * descriptions in any of your time probes, you must have
46
 
 * provided an event description table that maps the unsigned
47
 
 * longs to readable strings.  This map is a simple array of
48
 
 * strings, and the event number is used as the index into the
49
 
 * array when looking for the event description.  If you have
50
 
 * only used strings for the event description, this map is not
51
 
 * necessary.
52
 
 * Multiple maps can also be used to chunk up the time probes.
53
 
 * Each one can be added by calling <event_descriptions>.
54
 
 * Different tables are used internally by consulting the
55
 
 * minimum_id for each table.  It is up to the user to make sure
56
 
 * that multiple tables do not share the same event id range.
57
 
 */
58
 
template <class ACE_LOCK, class ALLOCATOR>
59
 
class ACE_Timeprobe_Ex
60
 
{
61
 
public:
62
 
 
63
 
  /// Self
64
 
  typedef ACE_Timeprobe_Ex<ACE_LOCK, ALLOCATOR>
65
 
          SELF;
66
 
 
67
 
  /**
68
 
   * ACE_Timeprobe
69
 
   */
70
 
  typedef ACE_Timeprobe_Ex <ACE_LOCK, ACE_Allocator> ACE_Timeprobe;
71
 
 
72
 
 
73
 
  /// We can hold multiple event description tables.
74
 
  typedef ACE_Unbounded_Set<ACE_Event_Descriptions>
75
 
          EVENT_DESCRIPTIONS;
76
 
 
77
 
  /// Create Timeprobes with <size> slots
78
 
  ACE_Timeprobe_Ex (u_long size = ACE_DEFAULT_TIMEPROBE_TABLE_SIZE);
79
 
 
80
 
  /// Create Timeprobes with <size> slots
81
 
  ACE_Timeprobe_Ex (ALLOCATOR *allocator,
82
 
                 u_long size = ACE_DEFAULT_TIMEPROBE_TABLE_SIZE);
83
 
  /// Destructor.
84
 
  ~ACE_Timeprobe_Ex (void);
85
 
 
86
 
  /// Record a time. <event> is used to describe this time probe.
87
 
  void timeprobe (u_long event);
88
 
 
89
 
  /// Record a time. <id> is used to describe this time probe.
90
 
  void timeprobe (const char *id);
91
 
 
92
 
  /// Record event descriptions.
93
 
  int event_descriptions (const char **descriptions,
94
 
                          u_long minimum_id);
95
 
 
96
 
  /// Print the time probes.
97
 
  void print_times (void);
98
 
 
99
 
  /// Print the time probes.
100
 
  void print_absolute_times (void);
101
 
 
102
 
  /// Reset the slots.  All old time probes will be lost.
103
 
  void reset (void);
104
 
 
105
 
  void increase_size (u_long size);
106
 
 
107
 
  /// Not implemented (stupid MSVC won't let it be protected).
108
 
  ACE_Timeprobe_Ex (const ACE_Timeprobe_Ex<ACE_LOCK, ALLOCATOR> &);
109
 
 
110
 
  // = (Somewhat private) Accessors
111
 
 
112
 
  /// Event Descriptions
113
 
  ACE_Unbounded_Set<ACE_Event_Descriptions> &event_descriptions (void);
114
 
 
115
 
  /// Sorted Event Descriptions.
116
 
  ACE_Unbounded_Set<ACE_Event_Descriptions> &sorted_event_descriptions (void);
117
 
 
118
 
  /// Find description of event \<i\>
119
 
  const char *find_description_i (u_long i);
120
 
 
121
 
  /// Sort event descriptions
122
 
  void sort_event_descriptions_i (void);
123
 
 
124
 
  /// Time probe slots
125
 
  ACE_timeprobe_t *timeprobes (void);
126
 
 
127
 
  /// Synchronization variable.
128
 
  ACE_LOCK &lock (void);
129
 
 
130
 
  /// Max size of timestamp table
131
 
  u_long max_size (void);
132
 
 
133
 
  /// Current size of timestamp table
134
 
  u_long current_size (void);
135
 
 
136
 
protected:
137
 
 
138
 
  /// Obtain an allocator pointer.  If there is no allocator stored in
139
 
  /// the instance, the singleton allocator in the current process is used.
140
 
  ALLOCATOR * allocator (void);
141
 
 
142
 
  /// Event Descriptions
143
 
  EVENT_DESCRIPTIONS event_descriptions_;
144
 
 
145
 
  /// Sorted Event Descriptions.
146
 
  EVENT_DESCRIPTIONS sorted_event_descriptions_;
147
 
 
148
 
  /// Time probe slots
149
 
  ACE_timeprobe_t *timeprobes_;
150
 
 
151
 
  /// Synchronization variable.
152
 
  ACE_LOCK lock_;
153
 
 
154
 
  /// Max size of timestamp table
155
 
  u_long max_size_;
156
 
 
157
 
  /// Current size of timestamp table
158
 
  u_long current_size_;
159
 
 
160
 
  /// flag indicating the report buffer has filled up, and is now
161
 
  /// acting as a ring-buffer using modulus arithmetic: this saves the
162
 
  /// max_size_ most recent time stamps and loses earlier ones until
163
 
  /// drained.
164
 
  u_short report_buffer_full_;
165
 
 
166
 
 
167
 
private:
168
 
   ALLOCATOR *   allocator_;
169
 
};
170
 
 
171
 
// template <class ACE_LOCK>
172
 
// class ACE_Timeprobe : public ACE_Timeprobe_Ex <ACE_LOCK, ACE_Allocator>
173
 
// {
174
 
// public:
175
 
//   // Initialize a ACE_Timeprobe with default size
176
 
//   ACE_Timeprobe (ACE_Allocator *allocator = ACE_Allocator::instance());
177
 
 
178
 
//   /// Create Timeprobes with <size> slots
179
 
//   ACE_Timeprobe (ACE_Allocator *allocator = ACE_Allocator::instance(),
180
 
//                  u_long size = ACE_DEFAULT_TIMEPROBE_TABLE_SIZE);
181
 
// };
182
 
 
183
 
/**
184
 
 * @class ACE_Function_Timeprobe
185
 
 *
186
 
 * @brief Auto pointer like time probes. It will record <event> on
187
 
 * construction and <event + 1> on destruction.
188
 
 */
189
 
template <class Timeprobe>
190
 
class ACE_Function_Timeprobe
191
 
{
192
 
public:
193
 
  /// Constructor.
194
 
  ACE_Function_Timeprobe (Timeprobe &timeprobe,
195
 
                          u_long event);
196
 
 
197
 
  /// Destructor.
198
 
  ~ACE_Function_Timeprobe (void);
199
 
 
200
 
protected:
201
 
  /// Reference to timeprobe.
202
 
  Timeprobe &timeprobe_;
203
 
 
204
 
  /// Event.
205
 
  u_long event_;
206
 
};
207
 
 
208
 
#if defined (ACE_TEMPLATES_REQUIRE_SOURCE)
209
 
#include "ace/Timeprobe_T.cpp"
210
 
#endif /* ACE_TEMPLATES_REQUIRE_SOURCE */
211
 
 
212
 
#if defined (ACE_TEMPLATES_REQUIRE_PRAGMA)
213
 
#pragma implementation ("Timeprobe_T.cpp")
214
 
#endif /* ACE_TEMPLATES_REQUIRE_PRAGMA */
215
 
 
216
 
#endif /* ACE_COMPILE_TIMEPROBES */
217
 
#include /**/ "ace/post.h"
218
 
#endif /* ACE_TIMEPROBE_T_H */