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

« back to all changes in this revision

Viewing changes to TAO/performance-tests/Sequence_Latency/Thread_Pool/client.cpp

  • 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
 
// client.cpp,v 1.3 2003/11/02 23:27:23 dhinton Exp
2
 
 
3
 
#include "Client_Task.h"
4
 
#include "ace/Get_Opt.h"
5
 
#include "ace/High_Res_Timer.h"
6
 
#include "ace/Sched_Params.h"
7
 
#include "ace/Stats.h"
8
 
#include "ace/OS_NS_errno.h"
9
 
 
10
 
#include "tao/Strategies/advanced_resource.h"
11
 
 
12
 
ACE_RCSID(Thread_Pool_Latency, client, "client.cpp,v 1.3 2003/11/02 23:27:23 dhinton Exp")
13
 
 
14
 
const char *ior = "file://test.ior";
15
 
int niterations = 1000;
16
 
int do_shutdown = 1;
17
 
int sz = 512;
18
 
 
19
 
const char *data_type = "octet";
20
 
 
21
 
int
22
 
parse_args (int argc, char *argv[])
23
 
{
24
 
  ACE_Get_Opt get_opts (argc, argv, "t:s:xk:i:");
25
 
  int c;
26
 
 
27
 
  while ((c = get_opts ()) != -1)
28
 
    switch (c)
29
 
      {
30
 
      case 't':
31
 
        data_type = get_opts.opt_arg ();
32
 
 
33
 
        if (ACE_OS::strcmp (data_type, "octet") != 0 &&
34
 
            ACE_OS::strcmp (data_type, "char") != 0 &&
35
 
            ACE_OS::strcmp (data_type, "long") != 0 &&
36
 
            ACE_OS::strcmp (data_type, "short") != 0 &&
37
 
            ACE_OS::strcmp (data_type, "double") != 0 &&
38
 
            ACE_OS::strcmp (data_type, "longlong") != 0)
39
 
          return -1;
40
 
        break;
41
 
 
42
 
          case 's':
43
 
        sz = ACE_OS::atoi (get_opts.opt_arg ());
44
 
        break;
45
 
 
46
 
      case 'x':
47
 
        do_shutdown = 0;
48
 
        break;
49
 
 
50
 
      case 'k':
51
 
        ior = get_opts.opt_arg ();
52
 
        break;
53
 
 
54
 
      case 'i':
55
 
        niterations = ACE_OS::atoi (get_opts.opt_arg ());
56
 
        break;
57
 
 
58
 
      case '?':
59
 
      default:
60
 
        ACE_ERROR_RETURN ((LM_ERROR,
61
 
                           "usage:  %s "
62
 
                           "-t <datatype> "
63
 
                                                   "-s <size> "
64
 
                           "-k <ior> "
65
 
                           "-i <niterations> "
66
 
                           "-x (disable shutdown) "
67
 
                           "\n",
68
 
                           argv [0]),
69
 
                          -1);
70
 
      }
71
 
  // Indicates sucessful parsing of the command line
72
 
  return 0;
73
 
}
74
 
 
75
 
int
76
 
main (int argc, char *argv[])
77
 
{
78
 
  int priority =
79
 
    (ACE_Sched_Params::priority_min (ACE_SCHED_FIFO)
80
 
     + ACE_Sched_Params::priority_max (ACE_SCHED_FIFO)) / 2;
81
 
  // Enable FIFO scheduling, e.g., RT scheduling class on Solaris.
82
 
 
83
 
  if (ACE_OS::sched_params (ACE_Sched_Params (ACE_SCHED_FIFO,
84
 
                                              priority,
85
 
                                              ACE_SCOPE_PROCESS)) != 0)
86
 
    {
87
 
      if (ACE_OS::last_error () == EPERM)
88
 
        {
89
 
          ACE_DEBUG ((LM_DEBUG,
90
 
                      "client (%P|%t): user is not superuser, "
91
 
                      "test runs in time-shared class\n"));
92
 
        }
93
 
      else
94
 
        ACE_ERROR ((LM_ERROR,
95
 
                    "client (%P|%t): sched_params failed\n"));
96
 
    }
97
 
 
98
 
  ACE_DECLARE_NEW_CORBA_ENV;
99
 
 
100
 
  ACE_TRY
101
 
    {
102
 
      CORBA::ORB_var orb =
103
 
        CORBA::ORB_init (argc, argv, "" ACE_ENV_ARG_PARAMETER);
104
 
      ACE_TRY_CHECK;
105
 
 
106
 
      if (parse_args (argc, argv) != 0)
107
 
        return 1;
108
 
 
109
 
      CORBA::Object_var object =
110
 
        orb->string_to_object (ior ACE_ENV_ARG_PARAMETER);
111
 
      ACE_TRY_CHECK;
112
 
 
113
 
      Test::Roundtrip_var roundtrip =
114
 
        Test::Roundtrip::_narrow (object.in () ACE_ENV_ARG_PARAMETER);
115
 
      ACE_TRY_CHECK;
116
 
 
117
 
      if (CORBA::is_nil (roundtrip.in ()))
118
 
        {
119
 
          ACE_ERROR_RETURN ((LM_ERROR,
120
 
                             "Nil Test::Roundtrip reference <%s>\n",
121
 
                             ior),
122
 
                            1);
123
 
        }
124
 
 
125
 
          /// Begin the test
126
 
 
127
 
      ACE_DEBUG ((LM_DEBUG, "Starting threads\n"));
128
 
 
129
 
      Client_Task task0 (data_type, sz, roundtrip.in (), niterations);
130
 
      Client_Task task1 (data_type, sz, roundtrip.in (), niterations);
131
 
      Client_Task task2 (data_type, sz, roundtrip.in (), niterations);
132
 
      Client_Task task3 (data_type, sz, roundtrip.in (), niterations);
133
 
 
134
 
      ACE_hrtime_t test_start = ACE_OS::gethrtime ();
135
 
      task0.activate (THR_NEW_LWP | THR_JOINABLE);
136
 
      task1.activate (THR_NEW_LWP | THR_JOINABLE);
137
 
      task2.activate (THR_NEW_LWP | THR_JOINABLE);
138
 
      task3.activate (THR_NEW_LWP | THR_JOINABLE);
139
 
 
140
 
      task0.thr_mgr()->wait ();
141
 
      ACE_hrtime_t test_end = ACE_OS::gethrtime ();
142
 
 
143
 
      ACE_DEBUG ((LM_DEBUG, "Threads finished\n"));
144
 
 
145
 
      ACE_DEBUG ((LM_DEBUG, "High resolution timer calibration...."));
146
 
      ACE_UINT32 gsf = ACE_High_Res_Timer::global_scale_factor ();
147
 
      ACE_DEBUG ((LM_DEBUG, "done\n"));
148
 
 
149
 
      ACE_Basic_Stats totals;
150
 
      task0.accumulate_and_dump (totals, "Task[0]", gsf);
151
 
      task1.accumulate_and_dump (totals, "Task[1]", gsf);
152
 
      task2.accumulate_and_dump (totals, "Task[2]", gsf);
153
 
      task3.accumulate_and_dump (totals, "Task[3]", gsf);
154
 
 
155
 
      totals.dump_results ("Total", gsf);
156
 
 
157
 
      ACE_Throughput_Stats::dump_throughput ("Total", gsf,
158
 
                                             test_end - test_start,
159
 
                                             totals.samples_count ());
160
 
 
161
 
      if (do_shutdown)
162
 
        {
163
 
          roundtrip->shutdown (ACE_ENV_SINGLE_ARG_PARAMETER);
164
 
          ACE_TRY_CHECK;
165
 
        }
166
 
    }
167
 
  ACE_CATCHANY
168
 
    {
169
 
      ACE_PRINT_EXCEPTION (ACE_ANY_EXCEPTION, "Exception caught:");
170
 
      return 1;
171
 
    }
172
 
  ACE_ENDTRY;
173
 
  ACE_CHECK_RETURN (-1);
174
 
 
175
 
  return 0;
176
 
}