Go to the documentation of this file. 9 #ifndef BALL_SYSTEM_TIMER_H 19 #define START_SECTION(name, weight) \ 20 BENCHMARK::section_time = BENCHMARK::timer.getCPUTime();\ 21 BENCHMARK::section_name = #name;\ 22 BENCHMARK::section_weight = weight; 29 BENCHMARK::timer.stop();\ 30 BENCHMARK::section_time = BENCHMARK::timer.getCPUTime() - BENCHMARK::section_time;\ 31 if (BENCHMARK::verbose > 0)\ 33 std::cout << BENCHMARK::section_name << ": " \ 34 << BENCHMARK::section_time << " s"\ 35 << " (weight = " << BENCHMARK::section_weight << ")" << std::endl;\ 37 BENCHMARK::total_time += BENCHMARK::section_time * BENCHMARK::section_weight;\ 45 if (BENCHMARK::verbose > 0)\ 47 std::cout << " status: " << a << std::endl;\ 60 BENCHMARK::timer.start();\ 72 BENCHMARK::timer.stop(); 79 #define START_BENCHMARK(class_name, overall_weight, version)\ 82 namespace BENCHMARK {\ 84 bool all_tests = true;\ 86 string exception_name = "";\ 87 const char* version_string = version;\ 88 string section_name = "";\ 89 float section_weight = 1.0;\ 90 float weight = overall_weight;\ 97 int main(int argc, char **argv)\ 101 if (!strcmp(argv[1], "-v"))\ 102 BENCHMARK::verbose = 1;\ 105 if ((argc > 2) || ((argc == 2) && (BENCHMARK::verbose == 0))) {\ 106 std::cerr << "Execute a benchmark for the " #class_name " class." << std::endl;\ 107 std::cerr << "Overall weight of the test: " << BENCHMARK::weight << std::endl;\ 109 std::cerr << "On successful operation, the total CPU time (in seconds)," << std::endl;\ 110 std::cerr << "is printed." << std::endl;\ 111 std::cerr << "If called with an argument of -v, " << argv[0] << " detailed" << std::endl;\ 112 std::cerr << "information about individual benchmarks is printed." << std::endl;\ 116 if (BENCHMARK::verbose > 0)\ 117 std::cout << "Version: " << BENCHMARK::version_string << std::endl;\ 124 #define END_BENCHMARK \ 128 catch (BALL::Exception::FileNotFound& e)\ 130 BENCHMARK::all_tests = false;\ 131 if (BENCHMARK::verbose > 1)\ 133 if (BENCHMARK::exception == 1) \ 134 BENCHMARK::exception++;\ 135 std::cout << std::endl << " (caught exception of type ";\ 136 std::cout << e.getName();\ 137 if ((e.getLine() > 0) && (!(e.getFile() == "")))\ 138 std::cout << " outside a benchmark block, which was thrown in line " << e.getLine() << " of file " << e.getFile();\ 139 std::cout << " while looking for file " << e.getFilename();\ 140 std::cout << " - unexpected!) " << std::endl;\ 144 catch (BALL::Exception::GeneralException& e)\ 146 BENCHMARK::all_tests = false;\ 147 if (BENCHMARK::verbose > 1)\ 149 if (BENCHMARK::exception == 1) \ 150 BENCHMARK::exception++;\ 151 std::cout << std::endl << " (caught exception of type ";\ 152 std::cout << e.getName();\ 153 if ((e.getLine() > 0) && (!(e.getFile() == "")))\ 154 std::cout << " outside a benchmark block, which was thrown in line " << e.getLine() << " of file " << e.getFile();\ 155 std::cout << " - unexpected!) " << std::endl;\ 161 BENCHMARK::all_tests = false;\ 162 if (BENCHMARK::verbose > 1)\ 164 std::cout << std::endl << " (caught unidentified and unexpected exception outside a benchmark block!) " << std::endl;\ 169 if (!BENCHMARK::all_tests)\ 171 std::cout << "(" << BENCHMARK::weight * BENCHMARK::total_time << ")" << std::endl;\ 174 std::cout << BENCHMARK::weight * BENCHMARK::total_time << std::endl;\