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
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
|
//=============================================================================
/**
* @file demux_stats.cpp
*
* @author Vishal Kachroo
*/
//=============================================================================
// FUZZ: disable check_for_math_include
#include <math.h>
#include "ace/Get_Opt.h"
#include "tao/corba.h"
class Demux_Stats
{
public:
/// Calculates the average latency and Standard deviation.
/// Expects the input data in my_results.dat.
int
calculate_avg_latency (void);
/// parses args.
int
Demux_Stats::parse_args (int argc_, char * argv_ []);
private :
/// temporary results file.
FILE *result_fp_;
int iterations;
};
// parse command line arguments (if any).
int
Demux_Stats::parse_args (int argc_, char * argv_ [])
{
ACE_Get_Opt get_opts (argc_, argv_, ACE_TEXT("i:"));
int c;
iterations = 0;
while ((c = get_opts ()) != -1)
switch (c)
{
case 'i':
iterations = ACE_OS::atoi (get_opts.opt_arg ());
break;
}
return 0;
}
int
Demux_Stats::calculate_avg_latency ()
{
CORBA::ULong i, time;
char str1[50], str2[50], str3[50];
double temp, mean_poa, mean_servant, mean_dispatch, mean_perfect, mean_dynamic, mean_binary, mean_linear, mean_parse;
double deviation_poa, deviation_servant, deviation_dispatch;
double std_deviation_poa, std_deviation_servant, std_deviation_dispatch;
double sum_poa_temp, sum_servant_temp, sum_dispatch_temp;
double time_temp, items_temp;
double items;
CORBA::ULong sum_poa, sum_servant, sum_dispatch, last_poa_time=0, last_servant_time=0, last_dispatch_time=0;
CORBA::ULong sum_linear, sum_dynamic, sum_binary, sum_perfect, sum_parse;
CORBA::ULong last_dynamic_time=0, last_linear_time=0, last_perfect_time=0, last_binary_time=0, last_parse_time = 0;
int counter;
if ((this->result_fp_ = ACE_OS::fopen ("my_results.dat", "r")) == 0)
{
ACE_ERROR_RETURN ((LM_ERROR,
"Demux_Test_Client::print_results - "
"Failed to open the results file for reading\n"),
-1);
}
sum_poa = 0;
sum_servant = 0;
sum_dispatch = 0;
sum_dynamic = 0;
sum_linear = 0;
sum_perfect = 0;
sum_binary = 0;
sum_parse = 0;
items = 0;
counter = 0;
while (fscanf (this->result_fp_, "%s %s %s %ld %ld", &str1, &str2, &str3, &i, &time) != EOF)
{
if(ACE_OS::strcmp (str1,"POA::locate_poa_i")==0 && (ACE_OS::strcmp (str3,"end") == 0))
{
if (items < 1) { items = items + 1; counter++; }
else
{
sum_poa += time;
last_poa_time = time;
items = items + 1;
++counter;
}
}
if(ACE_OS::strcmp (str1,"POA::find_servant")==0 && (ACE_OS::strcmp (str3,"end") == 0))
{
if (items < 1) { items = items + 1; counter++; }
else
{
sum_servant += time;
last_servant_time = time;
items = items + 1;
counter++;
}
}
if(ACE_OS::strcmp (str1,"Servant::_dispatch")==0 && (ACE_OS::strcmp (str3,"end") == 0))
{
if (items < 1) { ++items; counter++; }
else
{
sum_dispatch += time;
last_dispatch_time = time;
++items;items++;
counter++;
}
}
if(ACE_OS::strcmp (str1,"TAO_Dynamic_Hash_OpTable::find")==0 && (ACE_OS::strcmp (str3,"end") == 0))
{
if (items < 1) { ++items; counter++; }
else
{
sum_dynamic += time;
last_dynamic_time = time;
++items;
counter++;
}
}
if(ACE_OS::strcmp (str1,"TAO_Linear_Search_OpTable::find")==0 && (ACE_OS::strcmp (str3,"end") == 0))
{
if (items < 1) { items++; counter++; }
else
{
sum_linear += time;
last_linear_time = time;
items++;
counter++;
}
}
if(ACE_OS::strcmp (str1,"TAO_Perfect_Hash_OpTable::find")==0 && (ACE_OS::strcmp (str3,"end") == 0))
{
if (items < 1) { items++; counter++; }
else
{
sum_perfect += time;
last_perfect_time = time;
items++;
counter++;
}
}
if(ACE_OS::strcmp (str1,"TAO_Binary_Search_OpTable::find")==0 && (ACE_OS::strcmp (str3,"end") == 0))
{
if (items < 1) { items++; counter++; }
else
{
sum_binary += time;
last_binary_time = time;
items++;
counter++;
}
}
if(ACE_OS::strcmp (str1,"POA::parse_key")==0 && (ACE_OS::strcmp (str3,"end") == 0))
{
if (items < 1) { items++; counter++; }
else
{
sum_parse += time;
last_parse_time = time;
items++;
counter++;
}
}
if (iterations !=0 )
{
if (counter == iterations)
{
mean_poa = sum_poa/items;
mean_servant = sum_servant/items;
mean_dispatch = sum_dispatch/items;
mean_dynamic = sum_dynamic/items;
mean_linear = sum_linear/items;
mean_binary = sum_binary/items;
mean_perfect = sum_perfect/items;
ACE_OS::printf("Average response times = POA = %lf SERVANT = %lf DISPATCH = %lf PERFECT = %lf DYNAMIC = %lf BINARY = %lf LINEAR = %lf microsec\n",
mean_poa,
mean_servant,
mean_dispatch,
mean_perfect,
mean_dynamic,
mean_binary,
mean_linear);
sum_poa = 0;
sum_servant = 0;
sum_dispatch = 0;
sum_dynamic = 0;
sum_linear = 0;
sum_perfect = 0;
sum_binary = 0;
items = 0;
counter = 0;
}
}
}
ACE_OS::fclose (this->result_fp_);
if (iterations == 0)
{
sum_poa -= last_poa_time;
sum_servant -= last_servant_time;
sum_dispatch -= last_dispatch_time;
sum_dynamic -= last_dynamic_time;
sum_linear -= last_linear_time;
sum_perfect -= last_perfect_time;
sum_binary -= last_binary_time;
sum_parse -= last_parse_time;
//items = items - 4;
items = items - 2;
mean_poa = sum_poa/items;
mean_servant = sum_servant/items;
mean_dispatch = sum_dispatch/items;
mean_dynamic = sum_dynamic/items;
mean_linear = sum_linear/items;
mean_binary = sum_binary/items;
mean_perfect = sum_perfect/items;
mean_parse = sum_parse/items;
}
// now compute standard deviation
if ((this->result_fp_ = ACE_OS::fopen ("my_results.dat", "r")) == 0)
{
ACE_ERROR_RETURN ((LM_ERROR,
"Demux_Test_Client::print_results - "
"Failed to open the results file for reading\n"),
-1);
}
sum_poa_temp = 0;
sum_servant_temp = 0;
sum_dispatch_temp = 0;
deviation_poa = 0.0;
deviation_servant = 0.0;
deviation_dispatch = 0.0;
while (fscanf (this->result_fp_, "%s %s %s %ld %ld", &str1, &str2, &str3, &i, &time) != EOF)
{
time_temp = (double) time;
if(ACE_OS::strcmp (str1,"POA::locate_poa_i")==0 && (ACE_OS::strcmp (str3,"end") == 0))
{
deviation_poa = time_temp - mean_poa;
sum_poa_temp += deviation_poa * deviation_poa;
}
if(ACE_OS::strcmp (str1,"POA::find_servant")==0 && (ACE_OS::strcmp (str3,"end") == 0))
{
deviation_servant = time_temp - mean_servant;
sum_servant_temp += deviation_servant * deviation_servant;
}
if(ACE_OS::strcmp (str1,"Servant::_dispatch")==0 && (ACE_OS::strcmp (str3,"end") == 0))
{
deviation_dispatch = time_temp - mean_dispatch;
sum_dispatch_temp += deviation_dispatch * deviation_dispatch;
}
}
items_temp = (double) items;
if (items == 1)
{
std_deviation_poa = 0;
std_deviation_servant = 0;
std_deviation_dispatch = 0;
}
else
{
std_deviation_poa = sqrt (sum_poa_temp/(items_temp - 1));
std_deviation_servant = sqrt (sum_servant_temp/(items_temp - 1));
std_deviation_dispatch = sqrt (sum_dispatch_temp/(items_temp - 1));
}
// ACE_OS::unlink ("my_results.dat");
ACE_OS::fclose (this->result_fp_);
if (iterations == 0)
{
ACE_OS::printf("Average response times = POA = %lf SERVANT = %lf DISPATCH = %lf PERFECT = %lf DYNAMIC = %lf BINARY = %lf LINEAR = %lf PARSE = %lf microsec\n", mean_poa, mean_servant,
mean_dispatch,
mean_perfect,
mean_dynamic,
mean_binary,
mean_linear,
mean_parse);
}
return 0;
}
int
ACE_TMAIN(int argc, ACE_TCHAR *argv[])
{
Demux_Stats demux_stats;
demux_stats.parse_args (argc, argv);
demux_stats.calculate_avg_latency ();
}
|