summaryrefslogtreecommitdiff
path: root/TAO/tao/Timeprobe.h
blob: 99c29b148ef3cf6bd54d64dd3e2e5c93cb3909b7 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
//
// $Id$
//

#ifndef ACE_TIMEPROBE_H
#define ACE_TIMEPROBE_H

#include "ace/Synch.h"

class ACE_Timeprobe
{
public:
  static ACE_Timeprobe &instance ();

  void timeprobe (const char *id);

  void print_times () const;

  void reset();

  void destroy ();

private:
  ACE_Timeprobe ();
  ~ACE_Timeprobe ();

  ACE_Timeprobe (const ACE_Timeprobe &); // not implemented

private:
  static ACE_Timeprobe *instance_;

  enum { SLOTS = 8192 };

  ACE_SYNCH_MUTEX mutex_;

  u_int current_slot_;

  typedef struct timeprobe_info {
    const char *id_;
    ACE_hrtime_t time_;
    ACE_thread_t thread_;
  } timeprobe_t;
  timeprobe_t timeprobes [SLOTS];

  friend class null_friend_to_avoid_compiler_warning_about_no_friends;
};

#if defined (ACE_ENABLE_TIMEPROBES)
#  define ACE_TIMEPROBE_RESET ACE_Timeprobe::instance ().reset ()
#  define ACE_TIMEPROBE(id) ACE_Timeprobe::instance ().timeprobe (id)
#  define ACE_TIMEPROBE_PRINT ACE_Timeprobe::instance ().print_times ()
#  define ACE_TIMEPROBE_FINI ACE_Timeprobe::instance ().destroy ()
#else
#  define ACE_TIMEPROBE_RESET
#  define ACE_TIMEPROBE(id)
#  define ACE_TIMEPROBE_PRINT
#  define ACE_TIMEPROBE_FINI
#endif /* ACE_ENABLE_TIMEPROBES */

#if defined (__ACE_INLINE__)
#include "Timeprobe.i"
#endif /* __ACE_INLINE__ */

#endif /* ACE_TIMEPROBE_H */