diff --git a/src/main.cpp b/src/main.cpp index 4598f16..79612ee 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -1,8 +1,10 @@ #include "models/DeGroot.hpp" #include "simulation.hpp" +#include #include #include #include +#include #include #include #include @@ -50,10 +52,24 @@ int main( int argc, char * argv[] ) const std::optional n_output_agents = simulation.output_settings.n_output_agents; const std::optional n_output_network = simulation.output_settings.n_output_network; + + auto t_simulation_start = std::chrono::high_resolution_clock::now(); + auto print_progress = true; do { + auto t_iter_start = std::chrono::high_resolution_clock::now(); + simulation.model->iteration(); + auto t_iter_end = std::chrono::high_resolution_clock::now(); + auto iter_time = std::chrono::duration_cast( t_iter_end - t_iter_start ); + + // Print the iteration time? + if( print_progress ) + { + fmt::print( "Iteration {} iter_time = {:%Hh %Mm %Ss}\n", simulation.model->n_iterations, iter_time ); + } + // Write out the opinion? if( n_output_agents.has_value() && ( simulation.model->n_iterations % n_output_agents.value() == 0 ) ) { @@ -70,6 +86,11 @@ int main( int argc, char * argv[] ) } while( !simulation.model->finished() ); - fmt::print( "Finished after {} iterations.\n", simulation.model->n_iterations ); + auto t_simulation_end = std::chrono::high_resolution_clock::now(); + auto total_time = std::chrono::duration_cast( t_simulation_end - t_simulation_start ); + + fmt::print( "-----------------------------------------------------------------\n" ); + fmt::print( + "Finished after {} iterations, total time = {:%Hh %Mm %Ss}\n", simulation.model->n_iterations, total_time ); return 0; } \ No newline at end of file