diff --git a/benchmark.sh b/benchmark.sh index 27e078d..e740dcc 100755 --- a/benchmark.sh +++ b/benchmark.sh @@ -4,13 +4,13 @@ set -e BUILD_TYPE=Release ./build.sh &> /dev/null -MESSAGES=100 -PROCESSES=100 +MESSAGES=20 +PROCESSES=128 RUN_FOLDER=$(mktemp -d) HOSTS_FILE=$RUN_FOLDER/hosts OUTPUTS=$RUN_FOLDER/outputs CONFIG_FILE=$RUN_FOLDER/fifo-broadcast.config -SLEEP_TIME_S=3 +SLEEP_TIME_S=10 mkdir $OUTPUTS diff --git a/src/include/common.hpp b/src/include/common.hpp index c0daf1e..944c52a 100644 --- a/src/include/common.hpp +++ b/src/include/common.hpp @@ -52,7 +52,13 @@ class Perf { public: Perf() {} - template + inline auto mark() -> std::chrono::time_point { + return clock_t::now(); + } + + template inline auto since(std::string name, diff --git a/src/src/main.cpp b/src/src/main.cpp index 8449e7b..24afc19 100644 --- a/src/src/main.cpp +++ b/src/src/main.cpp @@ -3,6 +3,7 @@ #include #include #include +#include #include #include #include "common.hpp" @@ -38,19 +39,21 @@ struct Logger { inline auto write() -> void { if (_output.is_open()) { + std::stringstream ss; const auto& [sent_amount, delivered_size] = _frozen.value_or( std::make_tuple(static_cast(_sent_amount), static_cast(_delivered_size))); for (SendType n = _sent_amount_logged + 1; n <= sent_amount; n++) { - _output << "b " << n << std::endl; + ss << "b " << n << std::endl; } _sent_amount_logged = sent_amount; for (size_t i = 0; i < delivered_size; i++) { auto& [process_id, msg] = _delivered_buffer[i]; - _output << "d " << +process_id << " " << msg << std::endl; + ss << "d " << +process_id << " " << msg << std::endl; } + _output << ss.str(); } }