void stdout_printer::benchmark_result(const benchmark& info, const tables::table& results) { tables::table output = results; if (info.has_configurations()) { const auto& c = info.get_current_configuration(); for (const auto& v : c) { output.add_const_column(v.first, v.second); } } m_tables.insert(m_tables.end(), output); }
static void bm_rank(benchmark::State& state) { const auto br = gen_binary_relation(/*max_size=*/1'000'000, /*max_object=*/object_id(100'000), /*max_label=*/label_id(state.range(0))); while (state.KeepRunning()) { auto const max_object = gen_object(br); auto const max_label = gen_label(br); DoNotOptimize(br.rank(max_object, max_label)); } }
static void bm_count_distinct_labels(benchmark::State& state) { const auto br = gen_binary_relation(/*max_size=*/1'000'000, /*max_object=*/object_id(100'000), /*max_label=*/label_id(state.range(0))); while (state.KeepRunning()) { const auto obj_range = gen_object_range(br); const auto lab_range = gen_label_range(br); DoNotOptimize(br.count_distinct_labels(obj_range.first, obj_range.second, lab_range.first, lab_range.second)); } }
static void bm_nth_element_obj_maj(benchmark::State& state) { const auto br = gen_binary_relation(/*max_size=*/1'000'000, /*max_object=*/object_id(100'000), /*max_label=*/label_id(state.range(0))); while (state.KeepRunning()) { auto obj_start = gen_object(br); auto lab_range = gen_label_range(br); DoNotOptimize(br.nth_element(obj_start, lab_range.first, lab_range.second, 42, brwt::obj_major)); } }
static void bm_lower_bound(benchmark::State& state) { const auto br = gen_binary_relation(/*max_size=*/1'000'000, /*max_object=*/object_id(100'000), /*max_label=*/label_id(state.range(0))); while (state.KeepRunning()) { const auto lab_range = gen_label_range(br); auto start = gen_pair(br); start.label = clamp(start.label, lab_range.first, lab_range.second); DoNotOptimize(br.lower_bound(start, lab_range.first, lab_range.second, brwt::obj_major)); } }
inline double run_benchmark(benchmark & b) { boost::high_resolution_timer timer; std::vector<double> results; for (int i = 0; i != num_benchmarks; ++i) { b.prepare(i); timer.restart(); b(i); double t = timer.elapsed(); results.push_back(t); } return results.at(results.size()/2); // median }
void benchmark_result(const benchmark &info, const tables::table &results) { std::vector<uint64_t> iterations = results.values_as<uint64_t>("iterations"); statistics iter = calculate_statistics( iterations.cbegin(), iterations.cend()); // Describe the beginning of the run. std::cout << std::fixed << console::textgreen << "[ RUN ]" << console::textdefault << " " << info.testcase_name() << "." << info.benchmark_name() << " (" << results.rows() << (results.rows() == 1 ? " run " : " runs ") << "/ " << iter.m_mean << " " << (iter.m_mean == 1 ? "iteration" : "iterations") << ")" << std::endl; if(info.has_configurations()) { std::cout << console::textyellow << "[ CONFIG ]" << console::textdefault << " "; const auto& c = info.get_current_configuration(); bool first = true; tables::format f; for(const auto& v : c) { if(!first) std::cout << ","; first = false; std::cout << v.first << "="; f.print(std::cout, v.second); } std::cout << std::endl; } double time = static_cast<double>( boost::chrono::duration_cast<boost::chrono::microseconds>( m_benchmark_stop-m_benchmark_start).count()); std::cout << std::fixed << console::textyellow << "[ TIME ]" << console::textdefault << " " << (time / 1000) << " milliseconds" << std::endl; for(const auto& c_name : results.columns()) { if(c_name == "iterations") continue; if(c_name == "run_number") continue; if(print_column<double>(c_name,info.unit_text(),results)) continue; if(print_column<float>(c_name,info.unit_text(),results)) continue; if(print_column<uint64_t>(c_name,info.unit_text(),results)) continue; if(print_column<int64_t>(c_name,info.unit_text(),results)) continue; if(print_column<int32_t>(c_name,info.unit_text(),results)) continue; if(print_column<uint32_t>(c_name,info.unit_text(),results)) continue; if(print_column<int16_t>(c_name,info.unit_text(),results)) continue; if(print_column<uint16_t>(c_name,info.unit_text(),results)) continue; if(print_column<int8_t>(c_name,info.unit_text(),results)) continue; if(print_column<uint8_t>(c_name,info.unit_text(),results)) continue; } std::cout << console::textgreen << "[----------] " << console::textdefault << std::endl; }