FACT++  1.0
benchClient.cxx
Go to the documentation of this file.
1 #include <iostream>
2 using namespace std;
3 #include <dic.hxx>
4 
5 #define TEST_TIME 10
6 
7 char ServerName[128];
8 int MsgSize;
9 int Done = 0;
11 
12 class Service : public DimInfo
13 {
14  void infoHandler()
15  {
16  if(!Done)
17  {
18  MsgSize = getSize();
20  Done = 1;
21  }
22  NReceived++;
23  }
24 public :
25  Service(char *name) : DimInfo(name,(char *)"--") {/*nReceived = 0;*/}
26 };
27 
28 int 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 }
#define TEST_TIME
Definition: benchClient.cxx:5
int dic_get_id(char *name)
Definition: dic.c:2062
char ServerName[128]
Definition: benchClient.cxx:7
int i
Definition: db_dim_client.c:21
int getServices(const char *serviceName)
Definition: diccpp.cxx:849
STL namespace.
Definition: dic.hxx:31
Service(char *name)
Definition: benchClient.cxx:25
static char * getServerName()
Definition: diccpp.cxx:1296
void infoHandler()
Definition: benchClient.cxx:14
int NReceived
Definition: benchClient.cxx:10
int MsgSize
Definition: benchClient.cxx:8
int main(int argc, char *argv[])
Definition: benchClient.cxx:28
int getNextService(char *&service, char *&format)
Definition: diccpp.cxx:948
int Done
Definition: benchClient.cxx:9