10 #include <TStopwatch.h>
40 for (
int i = 0; i < iterations; i++) {
41 Int_t val = i * i - (i - 1);
42 printf(
"Value: %i\n", val);
48 for (
int i = 0; i < iterations; i++) {
49 Int_t val = i * i - (i - 1);
50 std::cout <<
"Value: " << val << std::endl;
56 for (
int i = 0; i < iterations; i++) {
57 Int_t val = i * i - (i - 1);
58 std::cerr <<
"Value: " << val << std::endl;
65 for (
int i = 0; i < iterations; i++) {
66 Int_t val = i * i - (i - 1);
73 for (
int i = 0; i < iterations; i++) {
74 Int_t val = i * i - (i - 1);
75 LOG(info) <<
"Value: " << val <<
" ";
81 for (
int i = 0; i < iterations; i++) {
82 Int_t val = i * i - (i - 1);
83 LOG(info) <<
"Value: " << val <<
" ";
84 LOG(debug) <<
"Value: " << val <<
" ";
98 void setSyncOutput(
bool decision) { std::ios_base::sync_with_stdio(decision); }
102 std::cerr <<
"Please call the program with the number of the test to run." << std::endl;
103 std::cerr <<
"The following tests are implemented:" << std::endl;
104 std::cerr <<
" 1. printf" << std::endl;
105 std::cerr <<
" 2. cout syncronised" << std::endl;
106 std::cerr <<
" 3. cout not synchronised" << std::endl;
107 std::cerr <<
" 4. cerr syncronised" << std::endl;
108 std::cerr <<
" 5. cerr not synchronised" << std::endl;
109 std::cerr <<
" 6. FairLogger printf implemetation" << std::endl;
110 std::cerr <<
" 7. FairLogger streamer implemetation" << std::endl;
114 void doCalculation(std::vector<Double_t> rtime, std::vector<Double_t> ctime)
117 sort(rtime.begin(), rtime.end());
118 rtime.erase(rtime.begin());
120 sort(ctime.begin(), ctime.end());
121 ctime.erase(ctime.begin());
124 Double_t ctime_sum = 0.0;
125 Double_t ctime_avg = 0.0;
126 Double_t rtime_sum = 0.0;
127 Double_t rtime_avg = 0.0;
128 for (
unsigned int i = 0; i < rtime.size(); i++) {
129 rtime_sum += rtime.at(i);
130 ctime_sum += ctime.at(i);
133 rtime_avg = rtime_sum / rtime.size();
134 ctime_avg = ctime_sum / ctime.size();
136 Double_t ctime_min = *min_element(ctime.begin(), ctime.end());
137 Double_t ctime_max = *max_element(ctime.begin(), ctime.end());
141 Double_t rtime_min = *min_element(rtime.begin(), rtime.end());
142 Double_t rtime_max = *max_element(rtime.begin(), rtime.end());
143 std::cout <<
"Discarding the lowest and highest value the" << std::endl;
144 std::cout <<
"average of " << rtime.size() <<
" measurements is calculated." << std::endl;
145 std::cout <<
"Real time (min, average, max): " << rtime_min <<
", " << rtime_avg <<
", " << rtime_max << std::endl;
146 std::cout <<
"CPU time (min, average, max): " << ctime_min <<
", " << ctime_avg <<
", " << ctime_max << std::endl;
149 int main(
int argc,
char* argv[])
160 int iterations = 1000000;
161 int time_measurements = 12;
173 std::cout <<
"Using printf for output" << std::endl;
181 int x = atoi(argv[1]);
184 std::vector<Double_t> rtime;
185 std::vector<Double_t> ctime;
189 for (
int meas = 0; meas < time_measurements; meas++) {
193 rtime.push_back(timer.RealTime());
194 ctime.push_back(timer.CpuTime());
198 std::cout <<
"Using printf for output" << std::endl;
201 for (
int meas = 0; meas < time_measurements; meas++) {
205 rtime.push_back(timer.RealTime());
206 ctime.push_back(timer.CpuTime());
210 std::cout <<
"Using syncronised cout for output" << std::endl;
214 for (
int meas = 0; meas < time_measurements; meas++) {
218 rtime.push_back(timer.RealTime());
219 ctime.push_back(timer.CpuTime());
223 std::cout <<
"Using non syncronised cout for output" << std::endl;
226 for (
int meas = 0; meas < time_measurements; meas++) {
230 rtime.push_back(timer.RealTime());
231 ctime.push_back(timer.CpuTime());
235 std::cout <<
"Using syncronised cerr for output" << std::endl;
239 for (
int meas = 0; meas < time_measurements; meas++) {
243 rtime.push_back(timer.RealTime());
244 ctime.push_back(timer.CpuTime());
248 std::cout <<
"Using non syncronised cerr for output" << std::endl;
251 for (
int meas = 0; meas < time_measurements; meas++) {
255 rtime.push_back(timer.RealTime());
256 ctime.push_back(timer.CpuTime());
260 std::cout <<
"Using logger printf output" << std::endl;
263 for (
int meas = 0; meas < time_measurements; meas++) {
267 rtime.push_back(timer.RealTime());
268 ctime.push_back(timer.CpuTime());
272 std::cout <<
"Using logger cout output" << std::endl;
276 for (
int meas = 0; meas < time_measurements; meas++) {
280 rtime.push_back(timer.RealTime());
281 ctime.push_back(timer.CpuTime());
285 std::cout <<
"Using logger printf output" << std::endl;
289 for (
int meas = 0; meas < time_measurements; meas++) {
293 rtime.push_back(timer.RealTime());
294 ctime.push_back(timer.CpuTime());
298 std::cout <<
"Using logger cout output" << std::endl;
302 for (
int meas = 0; meas < time_measurements; meas++) {
306 rtime.push_back(timer.RealTime());
307 ctime.push_back(timer.CpuTime());
311 std::cout <<
"Using logger cout output" << std::endl;
314 std::cout <<
"Option Unknown" << std::endl;
void setSyncOutput(bool decision)
void logToLoggerCoutTest(int iterations)
void logToCout(int iterations)
void logToLoggerCout(int iterations)
void doCalculation(std::vector< Double_t > rtime, std::vector< Double_t > ctime)
void logToPrintf(int iterations)
void logToCerr(int iterations)
void logToLoggerPrintf(int iterations)