summaryrefslogtreecommitdiff
path: root/TAO/performance-tests/CSD_Strategy/TestServant/Foo_Statistics.cpp
blob: 6fe6e95fcff30b5ee4611c8777e342ffc7a466c2 (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
// $Id$
#include "Foo_Statistics.h"
#include "Foo_ClientEngine.h"


Foo_Statistics::Foo_Statistics()
  : num_clients_(0),
    num_loops_(0)
{
  for (unsigned i = 0; i < 5; i++)
    {
      this->expected_[i] = 0;
      this->actual_[i] = 0;
    }
}


Foo_Statistics::~Foo_Statistics()
{
}


void
Foo_Statistics::init(unsigned num_clients, unsigned num_loops)
{
  this->num_clients_ = num_clients;
  this->num_loops_   = num_loops;
}


void
Foo_Statistics::expected(unsigned op_num, unsigned count)
{
  this->expected_[op_num-1] = count * this->num_clients_ * this->num_loops_;
}


void
Foo_Statistics::actual(unsigned op_num, unsigned count)
{
  this->actual_[op_num-1] += count;
}


bool
Foo_Statistics::actual_vs_expected()
{
  for (unsigned i = 0; i < 5; i++)
    {
      if (this->expected_[i] != this->actual_[i])
        {
          ACE_DEBUG((LM_DEBUG,
                     "Actual vs. Expected Results Failure: "
                     "op%d() expected: %d, got: %d\n",
                     i, this->expected_[i], this->actual_[i]));
          return false;
        }
    }

  return true;
}


unsigned
Foo_Statistics::total() const
{
  unsigned t = 0;

  for (unsigned i = 0 ; i < 5; i++)
    {
      t += this->expected_[i];
    }

  return t;
}