From 0ffc235741c9a059fb1cc4eadaea052f48646aa8 Mon Sep 17 00:00:00 2001 From: Guido Cossu Date: Fri, 19 May 2017 10:55:04 +0100 Subject: [PATCH] Adding more statistics to the Benchmark_comms. Min and max --- benchmarks/Benchmark_comms.cc | 88 ++++++++++++++++++++++++----------- 1 file changed, 61 insertions(+), 27 deletions(-) diff --git a/benchmarks/Benchmark_comms.cc b/benchmarks/Benchmark_comms.cc index d4c59785..ce881ef6 100644 --- a/benchmarks/Benchmark_comms.cc +++ b/benchmarks/Benchmark_comms.cc @@ -31,16 +31,31 @@ using namespace std; using namespace Grid; using namespace Grid::QCD; -void statistics(std::vector v, double &mean, double &std_err){ +struct time_statistics{ + double mean; + double err; + double min; + double max; + + void statistics(std::vector v){ double sum = std::accumulate(v.begin(), v.end(), 0.0); mean = sum / v.size(); std::vector diff(v.size()); - std::transform(v.begin(), v.end(), diff.begin(), [mean](double x) { return x - mean; }); + std::transform(v.begin(), v.end(), diff.begin(), [=](double x) { return x - mean; }); double sq_sum = std::inner_product(diff.begin(), diff.end(), diff.begin(), 0.0); - std_err = std::sqrt(sq_sum / (v.size()*(v.size() - 1))); -} + err = std::sqrt(sq_sum / (v.size()*(v.size() - 1))); + auto result = std::minmax_element(v.begin(), v.end()); + min = *result.first; + max = *result.second; +} +}; + +void header(){ + std::cout < t_time(Nloop); - double mean_time, std_err_time; + time_statistics timestat; std::cout<