23 #include "TStopwatch.h" 30 void TestSpeed(
const Int_t npower2 = 20,
const Int_t bsize = 10);
33 void TestSizeIF(Int_t nsec=36, Int_t nrows=159, Int_t
npoints=1000, Int_t bsize=10, Int_t mode=1);
41 gSystem->GetProcInfo(&procInfo);
42 return procInfo.fMemVirtual;
51 printf(
"\n\tTesting kDTree memory usage ...\n");
53 printf(
"\n\tTesting kDTree speed ...\n");
62 Float_t *data0 =
new Float_t[npoints*2];
67 data[1][i]= gRandom->Rndm();
68 data[0][i]= gRandom->Rndm();
70 Float_t before =
Mem();
72 Float_t after =
Mem();
73 printf(
"Memory usage %f KB\n",after-before);
76 printf(
"Memory leak %f KB\n", end-before);
81 void TestSpeed(
const Int_t npower2,
const Int_t bsize)
87 printf(
"Please specify a power of 2 greater than 10\n");
91 Int_t
npoints = Int_t(pow(2., npower2))*bsize;
92 Float_t *data0 =
new Float_t[npoints*2];
97 data[1][i]= gRandom->Rndm();
98 data[0][i]= gRandom->Rndm();
101 TGraph *g =
new TGraph(npower2-10);
102 g->SetMarkerStyle(7);
106 for(
int i=10; i<npower2; i++){
107 tpoints = Int_t(pow(2., i))*bsize;
109 kdtree =
new TKDTreeIF(tpoints, 2, bsize, data);
111 g->SetPoint(i-10, i, timer.CpuTime());
112 printf(
"npoints [%d] nodes [%d] cpu time %f [s]\n", tpoints, kdtree->GetNNodes(), timer.CpuTime());
126 Float_t before =
Mem();
127 for (Int_t isec=0; isec<nsec;isec++)
128 for (Int_t irow=0;irow<nrows;irow++){
131 Float_t after =
Mem();
132 printf(
"Memory usage %f\n",after-before);
151 Float_t rangey = 100;
152 Float_t rangez = 100;
153 Float_t drangey = 0.1;
154 Float_t drangez = 0.1;
157 Float_t *data0 =
new Float_t[npoints*2];
163 data[0][i] = gRandom->Uniform(-rangey, rangey);
164 data[1][i] = gRandom->Uniform(-rangez, rangez);
169 printf(
"building kdTree ...\n");
174 if(mode == 0)
return;
177 Float_t counteriter = 0;
178 Float_t counterfound = 0;
181 if (nloop) timer.Start(kTRUE);
184 for (Int_t kloop = 0;kloop<nloop;kloop++){
191 Float_t point[2]={data[0][i],data[1][i]};
192 Float_t delta[2]={drangey,drangez};
198 kdtree->FindInRangeA(point,delta,res,nfound,iter,bnode);
201 Bool_t isOK = kFALSE;
202 for (Int_t ipoint=0;ipoint<nfound;ipoint++)
203 if (res[ipoint]==i) isOK =kTRUE;
205 counterfound+=nfound;
224 if (nloop)
printf(
"Find nearest point:\t%f\t%f\t%f\n",countern, counteriter, counterfound);
void TestSizeIF(Int_t nsec=36, Int_t nrows=159, Int_t npoints=1000, Int_t bsize=10, Int_t mode=1)
printf("Chi2/npoints = %f\n", TMath::Sqrt(chi2/npoints))
void TestBuild(const Int_t npoints=1000000, const Int_t bsize=100)
void TestSpeed(const Int_t npower2=20, const Int_t bsize=10)
void TestkdtreeIF(Int_t npoints=1000, Int_t bsize=9, Int_t nloop=1000, Int_t mode=2)
class TKDTree< Int_t, Float_t > TKDTreeIF