source: branches/fscctrl_safety_limits/dim/src/benchmark/benchClient.cxx@ 18733

Last change on this file since 18733 was 18058, checked in by tbretz, 10 years ago
Updated to v20r11
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,(char *)"--") {/*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 if(argc){}
37 if(argv){}
38 br.getServices("BENCH_SERVICE_*");
39
40 while(br.getNextService(name, format)!= 0)
41 {
42 nServices++;
43 }
44 services = new Service*[nServices];
45 i = 0;
46 while(br.getNextService(name, format)!= 0)
47 {
48 services[i++] = new Service(name);
49 }
50 dic_get_id(clientName);
51 if((cltptr = strchr(clientName,'@')))
52 cltptr++;
53 sleep(5);
54 NReceived = 0;
55
56 sleep(TEST_TIME);
57
58 mps = NReceived/TEST_TIME;
59 if((srvptr = strchr(ServerName,'@')))
60 srvptr++;
61 cout << "Benchmark from "<< srvptr << " to " << cltptr << " :" << endl;
62 cout << "Server publishes " << nServices << " services of " << MsgSize << " bytes each"<< endl;
63 cout << "Result :" << endl;
64 cout << "\tMessages/s = " << mps << endl;
65 tpm = 1/(float)mps*1000;
66 cout << "\tTime(ms)/message = " << tpm << endl;
67 cout << "\tThroughput (Kb/s) = " << mps*MsgSize/1024 << endl;
68 return 1;
69}
Note: See TracBrowser for help on using the repository browser.