From d3f772308deceb5f940ca59b0800e578c956724d Mon Sep 17 00:00:00 2001 From: Stepan Fomenko Date: Mon, 13 Jul 2020 13:59:31 +0300 Subject: [PATCH] Improved benchmarks and calc time distribution --- CMakeLists.txt | 2 -- experiments/block_choice.cpp | 11 ++++++----- 2 files changed, 6 insertions(+), 7 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index ef8660b..4a59a04 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,7 +1,5 @@ project(multithread_experiments) cmake_minimum_required(VERSION 2.8.6) -set(CMAKE_CXX_STANDART 11) -set(CMAKE_CXX_STANDARD_REQUIRED ON) option(USE_SMSDK "Use libraries from SMSDK directory" 1) if(USE_SMSDK) diff --git a/experiments/block_choice.cpp b/experiments/block_choice.cpp index dbb07ff..4f56999 100644 --- a/experiments/block_choice.cpp +++ b/experiments/block_choice.cpp @@ -29,7 +29,7 @@ namespace sm { const std::chrono::microseconds calc_time; static std::chrono::microseconds random_time() { - float val = powf(rand() % 1000 / 1000.f, 10.f) * 100.f * 1000.f; + float val = powf(rand() % 1000 / 1000.f, 20.f) * 30.f * 1000.f; // std::cout << int(val) << std::endl; return std::chrono::microseconds(int(val)); } @@ -273,15 +273,16 @@ std::vector> check_performance(const PIVector>& duration_futures) { for (auto & future : duration_futures) future.wait(); std::cout << "durations for " << duration_futures.size() << " threads: "; - double sum_sync_time = 0., sum_calc_time = 0.; + double sum_sync_time = 0., sum_calc_time = 0., max_time = 0.; for (auto & future : duration_futures) { sm::time_report tr = future.get(); sum_sync_time += tr.sync_time_ms; sum_calc_time += tr.calc_time_ms; + if (tr.sync_time_ms + tr.calc_time_ms > max_time) max_time = tr.sync_time_ms + tr.calc_time_ms; std::cout << "(sync=" << (int)tr.sync_time_ms << "ms,calc=" << (int)tr.calc_time_ms << "ms) "; } if (duration_futures.size() > 1) { - std::cout << "sum_sync=" << (int)sum_sync_time << "ms,sum_calc=" << (int)sum_calc_time << "ms"; + std::cout << "sum_sync=" << (int)sum_sync_time << "ms,max_time=" << max_time << "ms"; } std::cout << std::endl; } @@ -289,8 +290,8 @@ void print_performance(std::vector>& duration_futur int main() { srand(time(nullptr)); - PIVector start_blocks = scheme_generate(200, 3, 4); - scheme_print(start_blocks); + PIVector start_blocks = scheme_generate(1000, 3, 4, 0.2); +// scheme_print(start_blocks); auto duration_futures = check_performance(start_blocks, 1); print_performance(duration_futures);