diff --git a/src/main_utils.cpp b/src/main_utils.cpp index 2c65156..9a57e41 100644 --- a/src/main_utils.cpp +++ b/src/main_utils.cpp @@ -44,7 +44,7 @@ void combine_json_(json* base_json_ptr, json* json_ptr) } -json get_final_json(OnePointObservables& obs1, PsiConfig& psiConfig, PsiBasin& psiBasin, AgingConfig& agingConfig, AgingBasin& agingBasin, EMaxt2& emaxt2) +json get_final_json(OnePointObservables& obs1, PsiConfig& psiConfig, PsiBasin& psiBasin, AgingConfig& agingConfig, AgingBasin& agingBasin, EMaxt2& emaxt2, const double elapsed) { json j; @@ -66,6 +66,8 @@ json get_final_json(OnePointObservables& obs1, PsiConfig& psiConfig, PsiBasin& p json emaxt2_json = emaxt2.as_json(); combine_json_(&j, &emaxt2_json); + j["elapsed"] = elapsed; + return j; } @@ -94,6 +96,10 @@ void execute(const int job_index, const utils::SimulationParameters const_params AgingBasin agingBasin(params, sys); EMaxt2 emaxt2(params, sys); + + // Time the entire simulation + auto t_start = std::chrono::high_resolution_clock::now(); + // Simulation clock is 0 before entering the while loop while (true) { @@ -124,14 +130,17 @@ void execute(const int job_index, const utils::SimulationParameters const_params if (simulation_clock > params.N_timesteps){break;} } + const double elapsed = utils::get_time_delta(t_start); + // When the simulation is complete, write everything to disk - const json j_final = get_final_json( + json j_final = get_final_json( obs1, psiConfig, psiBasin, agingConfig, agingBasin, - emaxt2 + emaxt2, + elapsed ); utils::json_to_file_no_format(j_final, fnames.json_final); } diff --git a/src/processing_utils.cpp b/src/processing_utils.cpp index d2bcf55..76304c9 100644 --- a/src/processing_utils.cpp +++ b/src/processing_utils.cpp @@ -353,6 +353,17 @@ json get_aging_basin_statistics(const std::vector results, const std::stri } +std::vector process_elapsed_time(const std::vector results) +{ + std::vector v; + for (auto &result : results) + { + v.push_back(result["elapsed"]); + } + return v; +} + + json load_grids() { @@ -429,6 +440,9 @@ void postprocess() j["aging_basin_S"] = get_aging_basin_statistics(results, "aging_basin_S"); } + j["elapsed"] = process_elapsed_time(results); + + j["grids"] = load_grids(); j["grids"]["psi"] = get_psi_grid(j["psi_config"]["mean"].size());