From 3d6b73100ac71ea3a80dcba6d2d3383820f4e96f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Joan=20Vallv=C3=A9=20Navarro?= <jvallve@iri.upc.edu> Date: Wed, 18 Nov 2020 14:04:25 +0100 Subject: [PATCH] accumulated and max values in profiling --- include/core/processor/processor_base.h | 16 ++++++++++++---- include/core/solver/solver_manager.h | 6 ++++-- src/processor/processor_base.cpp | 6 ++++-- src/solver/solver_manager.cpp | 18 ++++++++++++------ 4 files changed, 32 insertions(+), 14 deletions(-) diff --git a/include/core/processor/processor_base.h b/include/core/processor/processor_base.h index 852a52e45..a617c66bb 100644 --- a/include/core/processor/processor_base.h +++ b/include/core/processor/processor_base.h @@ -269,8 +269,10 @@ class ProcessorBase : public NodeBase, public std::enable_shared_from_this<Proce // PROFILING unsigned int n_capture_callback_; unsigned int n_kf_callback_; - std::chrono::microseconds duration_capture_; - std::chrono::microseconds duration_kf_; + std::chrono::microseconds acc_duration_capture_; + std::chrono::microseconds acc_duration_kf_; + std::chrono::microseconds max_duration_capture_; + std::chrono::microseconds max_duration_kf_; std::chrono::time_point<std::chrono::high_resolution_clock> start_capture_; std::chrono::time_point<std::chrono::high_resolution_clock> start_kf_; void startCaptureProfiling(); @@ -404,7 +406,10 @@ inline void ProcessorBase::startCaptureProfiling() inline void ProcessorBase::stopCaptureProfiling() { - duration_capture_ += std::chrono::duration_cast<std::chrono::microseconds>(std::chrono::high_resolution_clock::now() - start_capture_); + auto duration_capture = std::chrono::duration_cast<std::chrono::microseconds>(std::chrono::high_resolution_clock::now() - start_capture_); + + max_duration_capture_ = std::max(max_duration_capture_, duration_capture); + acc_duration_capture_ += duration_capture; } inline void ProcessorBase::startKFProfiling() @@ -414,7 +419,10 @@ inline void ProcessorBase::startKFProfiling() inline void ProcessorBase::stopKFProfiling() { - duration_kf_ += std::chrono::duration_cast<std::chrono::microseconds>(std::chrono::high_resolution_clock::now() - start_kf_); + auto duration_kf = std::chrono::duration_cast<std::chrono::microseconds>(std::chrono::high_resolution_clock::now() - start_kf_); + + max_duration_kf_ = std::max(max_duration_kf_, duration_kf); + acc_duration_kf_ += duration_kf; } inline bool ProcessorBase::isVotingActive() const diff --git a/include/core/solver/solver_manager.h b/include/core/solver/solver_manager.h index c2dce560c..d5d4619d8 100644 --- a/include/core/solver/solver_manager.h +++ b/include/core/solver/solver_manager.h @@ -72,8 +72,10 @@ class SolverManager // PROFILING unsigned int n_solve_; - std::chrono::microseconds duration_manager_; - std::chrono::microseconds duration_solver_; + std::chrono::microseconds acc_duration_manager_; + std::chrono::microseconds acc_duration_solver_; + std::chrono::microseconds max_duration_manager_; + std::chrono::microseconds max_duration_solver_; protected: diff --git a/src/processor/processor_base.cpp b/src/processor/processor_base.cpp index a4ff214e1..f9aef63f9 100644 --- a/src/processor/processor_base.cpp +++ b/src/processor/processor_base.cpp @@ -15,8 +15,10 @@ ProcessorBase::ProcessorBase(const std::string& _type, int _dim, ParamsProcessor sensor_ptr_(), n_capture_callback_(0), n_kf_callback_(0), - duration_capture_(0), - duration_kf_(0) + acc_duration_capture_(0), + acc_duration_kf_(0), + max_duration_capture_(0), + max_duration_kf_(0) { // WOLF_DEBUG("constructed +p" , id()); } diff --git a/src/solver/solver_manager.cpp b/src/solver/solver_manager.cpp index 8a9e15d6e..b99176419 100644 --- a/src/solver/solver_manager.cpp +++ b/src/solver/solver_manager.cpp @@ -13,8 +13,10 @@ SolverManager::SolverManager(const ProblemPtr& _problem) : SolverManager::SolverManager(const ProblemPtr& _problem, const ParamsSolverPtr& _params) : n_solve_(0), - duration_manager_(0), - duration_solver_(0), + acc_duration_manager_(0), + acc_duration_solver_(0), + max_duration_manager_(0), + max_duration_solver_(0), wolf_problem_(_problem), params_(_params) { @@ -135,16 +137,18 @@ std::string SolverManager::solve() std::string SolverManager::solve(const ReportVerbosity report_level) { - auto start = std::chrono::high_resolution_clock::now(); + auto start_manager = std::chrono::high_resolution_clock::now(); n_solve_++; // update problem update(); // call derived solver - auto start_derived = std::chrono::high_resolution_clock::now(); + auto start_solver = std::chrono::high_resolution_clock::now(); std::string report = solveDerived(report_level); - duration_solver_ += std::chrono::duration_cast<std::chrono::microseconds>(std::chrono::high_resolution_clock::now() - start_derived); + auto duration_solver = std::chrono::duration_cast<std::chrono::microseconds>(std::chrono::high_resolution_clock::now() - start_solver); + acc_duration_solver_ += duration_solver; + max_duration_solver_ = std::max(max_duration_solver_,duration_solver); // update StateBlocks with optimized state value. /// @todo whatif someone has changed the state notification during opti ?? @@ -159,7 +163,9 @@ std::string SolverManager::solve(const ReportVerbosity report_level) stateblock_statevector.first->setState(stateblock_statevector.second, false); // false = do not raise the flag state_updated_ } - duration_manager_ += std::chrono::duration_cast<std::chrono::microseconds>(std::chrono::high_resolution_clock::now() - start); + auto duration_manager = std::chrono::duration_cast<std::chrono::microseconds>(std::chrono::high_resolution_clock::now() - start_manager); + acc_duration_manager_ += duration_manager; + max_duration_manager_ = std::max(max_duration_manager_,duration_manager); return report; } -- GitLab