Improved benchmarks and calc time distribution

This commit is contained in:
2 changed files with 6 additions and 7 deletions

View File

@@ -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)

View File

@@ -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<std::future<sm::time_report>> check_performance(const PIVector<sm::b
void print_performance(std::vector<std::future<sm::time_report>>& 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<std::future<sm::time_report>>& duration_futur
int main() {
srand(time(nullptr));
PIVector<sm::block*> start_blocks = scheme_generate(200, 3, 4);
scheme_print(start_blocks);
PIVector<sm::block*> 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);