29 std::cout <<
"Generating random vector of '"
30 << type <<
"' and size " << size <<
" ..." << std::endl << std::endl;
33 double totalUnitTime = 0;
35 T *vector =
new T[size];
39 for (
unsigned int i = 0; i < size; ++i )
40 std::cout << vector[i] <<
" " << std::endl;
44 std::cout.precision(6);
46 unsigned int ntest = 3 *
NUMTEST;
48 volatile int iresult = 0;
49 for (
unsigned int i = 0; i < ntest; ++i )
52 std::cout <<
"MinMaxElement() \tTotal Time: " <<
Time(w) <<
" (s)\t\t"
53 <<
" Time/call: " <<
Time(w)/(ntest)*1.E6 <<
" (microsec)" << std::endl;
54 totalUnitTime +=
Time(w)/ntest;
59 for (
unsigned int i = 0; i < ntest; ++i )
62 std::cout <<
"LocMin/Max() \t\tTotal Time: " <<
Time(w) <<
" (s)\t\t"
63 <<
" Time/call: " <<
Time(w)/(ntest)*1.E6 <<
" (microsec)" << std::endl;
64 totalUnitTime +=
Time(w)/ntest;
70 for (
unsigned int i = 0; i < ntest; ++i )
73 std::cout <<
"Mean() \t\t\tTotal Time: " <<
Time(w) <<
" (s)\t\t"
74 <<
" Time/call: " <<
Time(w)/(ntest)*1.E6 <<
" (microsec)" << std::endl;
75 totalUnitTime +=
Time(w)/ntest;
78 ntest = (
unsigned int) (
NUMTEST/2.5 );
80 for (
unsigned int i = 0; i < ntest; ++i )
83 std::cout <<
"Median() \t\tTotal Time: " <<
Time(w) <<
" (s)\t\t"
84 <<
" Time/call: " <<
Time(w)/(ntest)*1.E6 <<
" (microsec)" << std::endl;
85 totalUnitTime +=
Time(w)/ntest;
88 ntest = (
unsigned int) ( 10 *
NUMTEST );
90 for (
unsigned int i = 0; i < ntest; ++i )
93 std::cout <<
"RMS() \t\t\tTotal Time: " <<
Time(w) <<
" (s)\t\t"
94 <<
" Time/call: " <<
Time(w)/(ntest)*1.E6 <<
" (microsec)" << std::endl;
95 totalUnitTime +=
Time(w)/ntest;
98 ntest = (
unsigned int) (
NUMTEST/2.5 );
100 for (
unsigned int i = 0; i < ntest; ++i )
103 std::cout <<
"GeomMean() \t\tTotal Time: " <<
Time(w) <<
" (s)\t\t"
104 <<
" Time/call: " <<
Time(w)/(ntest)*1.E6 <<
" (microsec)" << std::endl;
105 totalUnitTime +=
Time(w)/ntest;
106 totalTime +=
Time(w);
111 for (
unsigned int i = 0; i < ntest; ++i )
114 std::cout <<
"Sort() \t\t\tTotal Time: " <<
Time(w) <<
" (s)\t\t"
115 <<
" Time/call: " <<
Time(w)/(ntest)*1.E6 <<
" (microsec)" << std::endl;
116 totalUnitTime +=
Time(w)/ntest;
117 totalTime +=
Time(w);
119 std::sort(vector, vector + size);
121 for (
unsigned int i = 0; i < size; ++i )
122 std::cout << vector[i] <<
" " << std::endl;
126 for (
unsigned int i = 0; i < ntest; ++i )
129 std::cout <<
"BinarySearch() \t\tTotal Time: " <<
Time(w) <<
" (s)\t\t"
130 <<
" Time/call: " <<
Time(w)/(ntest)*1.E6 <<
" (microsec)" << std::endl;
131 totalUnitTime +=
Time(w)/ntest;
132 totalTime +=
Time(w);
134 std::cout <<
"\nTotal Time : " << totalTime <<
" (s)\n"
135 <<
"Total Time/call : " << totalUnitTime*1.E3 <<
" (ms)\n" << std::endl;
144 return totalUnitTime;
149 double totalTime = 0;
151 std::cout <<
"Stress Test Start..." << std::endl;
153 if ( strcmp(type,
"Short_t") == 0 )
154 totalTime += stressVector<Short_t>(size,
type);
155 else if ( strcmp(type,
"Int_t") == 0 )
156 totalTime += stressVector<Int_t>(size, type);
157 else if ( strcmp(type,
"Float_t") == 0 )
158 totalTime += stressVector<Float_t>(size, type);
159 else if ( strcmp(type,
"Long_t") == 0 )
160 totalTime += stressVector<Long_t>(size, type);
161 else if ( strcmp(type,
"Long64_t") == 0 )
162 totalTime += stressVector<Long64_t>(size, type);
164 totalTime += stressVector<Double_t>(size,
"Double_t");
168 std::cout <<
"End of Stress Test..." << std::endl;
174 int main(
int argc,
char* argv[])
177 unsigned int size = 100000;
178 const char *
type =
"Double_t";
181 if (strcmp(argv[1],
"-h") == 0) {
182 std::cout <<
"Usage: " << argv[0]
183 <<
" [TYPE OF ARRAY] [SIZE OF ARRAY]\n\n"
184 <<
"where [TYPE OF ARRAY] is one of the following:\n"
189 <<
"\t\"Long64_t\"\n"
190 <<
"\t \"Double_t\"\n"
199 size = (
unsigned int) atoi(argv[2]);
Double_t RealTime()
Stop the stopwatch (if it is running) and return the realtime (in seconds) passed between the start a...
void Start(Bool_t reset=kTRUE)
Start the stopwatch.
Random number generator class based on the maximally quidistributed combined Tausworthe generator by ...
void generate(R &r, TH1D *h)
Double_t GeomMean(Long64_t n, const T *a)
Double_t RMS(Long64_t n, const T *a, const Double_t *w=0)
void Stop()
Stop the stopwatch.
double stressVector(unsigned int size, const char *type)
void stressTMath(unsigned int size, const char *type)
void Sort(Index n, const Element *a, Index *index, Bool_t down=kTRUE)
Double_t Mean(Long64_t n, const T *a, const Double_t *w=0)
Double_t Median(Long64_t n, const T *a, const Double_t *w=0, Long64_t *work=0)
virtual Double_t Uniform(Double_t x1=1)
Returns a uniform deviate on the interval (0, x1).
int main(int argc, char *argv[])
double Time(TStopwatch &w)
typedef void((*Func_t)())
const unsigned int NUMTEST
Long64_t LocMin(Long64_t n, const T *a)
Long64_t BinarySearch(Long64_t n, const T *array, T value)
T MinElement(Long64_t n, const T *a)