source: trunk/FACT++/dim/src/benchmark/benchClient.cxx@ 13135

Last change on this file since 13135 was 11071, checked in by tbretz, 13 years ago
Replaced v19r21 by a version extracted with 'unzip -a' to get proper unix text format.
File size: 1.4 KB
Line 
1#include <iostream>
2using namespace std;
3#include <dic.hxx>
4
5#define TEST_TIME 10
6
7char ServerName[128];
8int MsgSize;
9int Done = 0;
10int NReceived;
11
12class Service : public DimInfo
13{
14 void infoHandler()
15 {
16 if(!Done)
17 {
18 MsgSize = getSize();
19 strcpy(ServerName, DimClient::getServerName());
20 Done = 1;
21 }
22 NReceived++;
23 }
24public :
25 Service(char *name) : DimInfo(name,"--") {/*nReceived = 0;*/}
26};
27
28int main(int argc, char *argv[])
29{
30 int i, nServices = 0;
31 Service **services;
32 float mps,tpm;
33 DimBrowser br;
34 char *name, *format, *cltptr, *srvptr, clientName[128];
35
36 br.getServices("BENCH_SERVICE_*");
37
38 while(br.getNextService(name, format)!= 0)
39 {
40 nServices++;
41 }
42 services = new Service*[nServices];
43 i = 0;
44 while(br.getNextService(name, format)!= 0)
45 {
46 services[i++] = new Service(name);
47 }
48 dic_get_id(clientName);
49 if(cltptr = strchr(clientName,'@'))
50 cltptr++;
51 sleep(5);
52 NReceived = 0;
53
54 sleep(TEST_TIME);
55
56 mps = NReceived/TEST_TIME;
57 if(srvptr = strchr(ServerName,'@'))
58 srvptr++;
59 cout << "Benchmark from "<< srvptr << " to " << cltptr << " :" << endl;
60 cout << "Server publishes " << nServices << " services of " << MsgSize << " bytes each"<< endl;
61 cout << "Result :" << endl;
62 cout << "\tMessages/s = " << mps << endl;
63 tpm = 1/(float)mps*1000;
64 cout << "\tTime(ms)/message = " << tpm << endl;
65 cout << "\tThroughput (Kb/s) = " << mps*MsgSize/1024 << endl;
66 return 1;
67}
Note: See TracBrowser for help on using the repository browser.