00001 void hclient(Bool_t evol=kFALSE)
00002 {
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021 gBenchmark->Start("hclient");
00022
00023
00024 TSocket *sock = new TSocket("localhost", 9090);
00025
00026
00027 char str[32];
00028 sock->Recv(str, 32);
00029
00030
00031 int idx = !strcmp(str, "go 0") ? 0 : 1;
00032
00033 Float_t messlen = 0;
00034 Float_t cmesslen = 0;
00035 if (idx == 1)
00036 sock->SetCompressionLevel(1);
00037
00038 TH1 *hpx;
00039 if (idx == 0) {
00040
00041 hpx = new TH1F("hpx","This is the px distribution",100,-4,4);
00042 hpx->SetFillColor(48);
00043 } else {
00044 hpx = new TH2F("hpxpy","py vs px",40,-4,4,40,-4,4);
00045 }
00046
00047 TMessage::EnableSchemaEvolutionForAll(evol);
00048 TMessage mess(kMESS_OBJECT);
00049
00050
00051
00052 gRandom->SetSeed();
00053 Float_t px, py;
00054 const int kUPDATE = 1000;
00055 for (int i = 0; i < 25000; i++) {
00056 gRandom->Rannor(px,py);
00057 if (idx == 0)
00058 hpx->Fill(px);
00059 else
00060 hpx->Fill(px,py);
00061 if (i && (i%kUPDATE) == 0) {
00062 mess.Reset();
00063 mess.WriteObject(hpx);
00064 sock->Send(mess);
00065 messlen += mess.Length();
00066 cmesslen += mess.CompLength();
00067 }
00068 }
00069 sock->Send("Finished");
00070
00071 if (cmesslen > 0)
00072 printf("Average compression ratio: %g\n", messlen/cmesslen);
00073
00074 gBenchmark->Show("hclient");
00075
00076
00077 sock->Close();
00078 }