38 return fData[i1] > fData[i2];
45 template <
typename T>
bool testSort(
const int n,
double* tTMath,
double* tStd)
48 std::cout <<
"Testing Sort of array - size n = " << n <<
"\t(Time / call in microsec.) " << std::endl;
57 for (
Int_t i = 0; i <
n; i++) {
66 for (
int j = 0; j <
npass; ++j) {
72 cout <<
"TMath::Sort time :\t\t " << *tTMath << endl;
76 for (
int j = 0; j <
npass; ++j) {
77 for(
Int_t i = 0; i <
n; i++) { index2[i] = i; }
78 std::sort(&index2[0],&index2[0]+n, Compare<T>(&k[0]) );
82 std::cout <<
"std::sort time (using indices):\t " << *tStd << std::endl;
86 for(
Int_t i = 0; i < n && ok; i++) {
87 ok &= (index[i] == index2[i]);
88 if (!ok)
Error(
"test sort",
"Different values found at i= %d - index1 = %d - index2 = %d",i,index[i],index2[i]);
105 ok &= testSort<Int_t>(i, &tM[j], &tS[j]);
113 cout <<
" TMATH - time --- std time " << std::endl;
114 for ( i = 0; i < ntest; ++i) {
115 cout <<
" size = " << index[i] <<
" : " << tM[i] <<
' ' << tS[i] << endl;
137 legend->
AddEntry(gM,
"TMath::Sort()");
138 legend->
AddEntry(gS,
"std::sort()");
144 hpx->
SetTitle(
"Comparison of Sorting Time");
154 int main(
int argc,
char **argv)
158 for (
Int_t i=1 ; i<argc ; i++) {
159 std::string arg = argv[i] ;
168 cerr <<
"Usage: " << argv[0] <<
" [-g] [-v]\n";
170 cerr <<
" -g : graphics mode\n";
171 cerr <<
" -v : verbose mode";
virtual void SetLineWidth(Width_t lwidth)
Set the line width.
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.
virtual void SetTitle(const char *title="")
Set graph title.
TRObject operator()(const T1 &t1) const
virtual void Draw(Option_t *chopt="")
Draw this graph 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,...)
virtual void SetLineColor(Color_t lcolor)
Set the line color.
virtual void SetMarkerStyle(Style_t mstyle=1)
Set the marker style.
TH1F * GetHistogram() const
Returns a pointer to the histogram used to draw the axis Takes into account the two following cases...
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)
A Graph is a graphics object made of two arrays X and Y with npoints each.
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="")
Set the title of the TNamed.
bool testSort(const int n, double *tTMath, double *tStd)