37 return fData[i1] > fData[i2];
43 template <
typename T>
bool testSort(
const int n,
double* tTMath,
double* tStd)
46 std::cout <<
"Testing Sort of array - size n = " << n <<
"\t(Time / call in microsec.) " << std::endl;
55 for (
Int_t i = 0; i <
n; i++) {
64 for (
int j = 0; j <
npass; ++j) {
70 cout <<
"TMath::Sort time :\t\t " << *tTMath << endl;
74 for (
int j = 0; j <
npass; ++j) {
75 for(
Int_t i = 0; i <
n; i++) { index2[i] = i; }
76 std::sort(&index2[0],&index2[0]+n, Compare<T>(&k[0]) );
80 std::cout <<
"std::sort time (using indices):\t " << *tStd << std::endl;
84 for(
Int_t i = 0; i < n && ok; i++) {
85 ok &= (index[i] == index2[i]);
86 if (!ok)
Error(
"test sort",
"Different values found at i= %d - index1 = %d - index2 = %d",i,index[i],index2[i]);
103 ok &= testSort<Int_t>(i, &tM[j], &tS[j]);
111 cout <<
" TMATH - time --- std time " << std::endl;
112 for (
int i = 0; i < ntest; ++i) {
113 cout <<
" size = " << index[i] <<
" : " << tM[i] <<
' ' << tS[i] << endl;
119 TCanvas*
c1 =
new TCanvas(
"c1",
"Comparision of Sorting Time", 600, 400);
121 TGraph* gM =
new TGraph(ntest, &index[0], &tM[0]);
124 gM->SetMarkerStyle(20);
125 gM->SetTitle(
"TMath::Sort()");
128 TGraph* gS =
new TGraph(
arraysize, &index[0], &tS[0]);
131 gS->SetTitle(
"std::sort()");
135 legend->
AddEntry(gM,
"TMath::Sort()");
136 legend->
AddEntry(gS,
"std::sort()");
139 TH1 *
hpx = gM->GetHistogram();
142 hpx->
SetTitle(
"Comparison of Sorting Time");
152 int main(
int argc,
char **argv)
156 for (
Int_t i=1 ; i<argc ; i++) {
157 std::string arg = argv[i] ;
166 cerr <<
"Usage: " << argv[0] <<
" [-g] [-v]\n";
168 cerr <<
" -g : graphics mode\n";
169 cerr <<
" -v : verbose mode";
Double_t RealTime()
Stop the stopwatch (if it is running) and return the realtime (in seconds) passed between the start a...
This class displays a legend box (TPaveText) containing several legend entries.
void Start(Bool_t reset=kTRUE)
Start the stopwatch.
Random number generator class based on the maximally quidistributed combined Tausworthe generator by ...
virtual void Draw(Option_t *option="")
Draw this legend with its current attributes.
void Stop()
Stop the stopwatch.
virtual void Run(Bool_t retrn=kFALSE)
Main application eventloop. Calls system dependent eventloop via gSystem.
virtual UInt_t Integer(UInt_t imax)
Returns a random integer on [ 0, imax-1 ].
void Sort(Index n, const Element *a, Index *index, Bool_t down=kTRUE)
void Error(const char *location, const char *msgfmt,...)
TRObject operator()(const T1 &t1) const
TLegendEntry * AddEntry(const TObject *obj, const char *label="", Option_t *option="lpf")
Add a new entry to this legend.
int main(int argc, char **argv)
Int_t Compare(const void *item1, const void *item2)
This class creates the ROOT Application Environment that interfaces to the windowing system eventloop...
virtual void SetTitle(const char *title)
Change (i.e.
virtual void SetTitle(const char *title="")
Change (i.e. set) the title of the TNamed.
bool testSort(const int n, double *tTMath, double *tStd)