summaryrefslogtreecommitdiff
path: root/TAO/orbsvcs/tests/EC_Throughput/ECT_Driver.h
blob: 0a5b96dbc92e9484459c40d840a04c22142c14f1 (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
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
/* -*- C++ -*- */
// $Id$
//
// ============================================================================
//
// = DESCRIPTION
//   Abstract base class for the test driver, this let us implement a
//   collocated and a non-collocated test.
//
// ============================================================================

#ifndef ECT_DRIVER_H
#define ECT_DRIVER_H

#include "tao/corba.h"

class ECT_Driver
{
  //
  // = TITLE
  //
  // = DESCRIPTION
  //
public:
  virtual ~ECT_Driver (void);

  virtual void shutdown_consumer (void* consumer_cookie,
                                  CORBA::Environment&) = 0;
  // Callback method for consumers, each consumer will call this
  // method once it receives all the shutdown events from the
  // suppliers.

  void end_to_end (ACE_hrtime_t sample);
  void supplier_to_ec (ACE_hrtime_t sample);
  void inside_ec (ACE_hrtime_t sample);
  void ec_to_consumer (ACE_hrtime_t sample);

  void dump_latency_results (const char* description);

  class Latency_Stats
  {
    // = TITLE
    //   Maintains latency statistics.
    //
    // = DESCRIPTION
    //   This class is used to keep latency statistics of the Event
    //   Channel, in the future we could keep a histogram, but at the
    //   moment we just keep track of minimum, maximum, average and
    //   variance.
    //   The data should be  collected using the High Resolution
    //   timers.
  public:
    Latency_Stats (void);

    void dump_results (const char* test_name,
                       const char* sub_test);

    void sample (ACE_hrtime_t sample);

    void accumulate (const Latency_Stats& stats);
    // Useful to merge several Latency_Stats.

  private:
    u_long n_;
    ACE_hrtime_t sum_;
    ACE_hrtime_t sum2_;
    ACE_hrtime_t min_;
    ACE_hrtime_t max_;
  };

  class Throughput_Stats
  {
    // = TITLE
    //   Maintains throughput statistics.
    //
    // = DESCRIPTION
    //   This class is used to keep throughput statistics of the Event
    //   Channel.
    //   The data should be  collected using the High Resolution
    //   timers.
  public:
    Throughput_Stats (void);

    void dump_results (const char* test_name,
                       const char* sub_test);

    void start (void);
    // Start measuring the time.

    void stop (void);
    // The test has completed

    void sample (void);
    // An event has been received

    void accumulate (const Throughput_Stats& stats);
    // Useful to merge several Throughput_Stats.

  private:
    CORBA::ULong n_;
    int done_;
    ACE_hrtime_t start_;
    ACE_hrtime_t stop_;
  };

private:
  Latency_Stats end_to_end_;
  Latency_Stats supplier_to_ec_;
  Latency_Stats inside_ec_;
  Latency_Stats ec_to_consumer_;
};

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

#endif /* ECT_CONSUMER_H */