diff --git a/src/processor/processor_base.cpp b/src/processor/processor_base.cpp index 6390ce2e33947bbc67c600a63739378e8e6d6f52..72b5bbb2c610e3905c154108df1673025e29fd7e 100644 --- a/src/processor/processor_base.cpp +++ b/src/processor/processor_base.cpp @@ -240,19 +240,38 @@ bool ProcessorBase::check(CheckLog& _log, bool _verbose, std::ostream& _stream, void ProcessorBase::printProfiling(std::ostream& _stream) const { + unsigned int kf_average_period = + (n_kf_callback_ > 0) ? std::round(100 * capture_period_mean_ * n_capture_callback_ / n_kf_callback_) : 0; + unsigned int average_proc_cap_percent = + (n_capture_callback_ > 0) + ? std::round(100 * acc_duration_capture_.count() / n_capture_callback_ / capture_period_mean_) + : 0; + unsigned int max_proc_cap_percent = + (n_capture_callback_ > 0) ? std::round(100 * max_duration_capture_.count() / capture_period_min_) : 0; + unsigned int average_proc_kf_percent = + (n_kf_callback_ > 0) ? std::round(100 * acc_duration_kf_.count() / n_kf_callback_ / kf_average_period) : 0; + unsigned int max_proc_kf_percent = + (n_kf_callback_ > 0) ? std::round(100 * max_duration_kf_.count() / kf_average_period) : 0; + _stream << "\n" << getType() << " - " << getName() << ":" - << "\n\ttotal time: " << 1e-6 * (acc_duration_capture_ + acc_duration_kf_).count() << " s" + << "\n\ttotal proc. time: " << 1e-6 * (acc_duration_capture_ + acc_duration_kf_).count() << " s" << "\n\tProcessing captures:" - << "\n\t\ttotal time: " << 1e-6 * acc_duration_capture_.count() << " s" << "\n\t\tcaptures processed: " << n_capture_callback_ - << "\n\t\taverage time: " << 1e-3 * acc_duration_capture_.count() / n_capture_callback_ << " ms" - << "\n\t\tmax time: " << 1e-3 * max_duration_capture_.count() << " ms" + << "\n\t\taverage period: " << 1e-3 * capture_period_mean_ << " ms" + << "\n\t\ttotal proc. time: " << 1e-6 * acc_duration_capture_.count() << " s" + << "\n\t\taverage proc. time: " << 1e-3 * acc_duration_capture_.count() / n_capture_callback_ << " ms" + << " (" << average_proc_cap_percent << "%)" + << "\n\t\tmax proc. time: " << 1e-3 * max_duration_capture_.count() << " ms" + << " (" << max_proc_cap_percent << "%)" << "\n\tProcessing keyframes:" - << "\n\t\ttotal time: " << 1e-6 * acc_duration_kf_.count() << " s" << "\n\t\tkf processed: " << n_kf_callback_ - << "\n\t\taverage time: " << 1e-3 * acc_duration_kf_.count() / n_kf_callback_ << " ms" - << "\n\t\tmax time: " << 1e-3 * max_duration_kf_.count() << " ms" << std::endl; + << "\n\t\taverage period: " << 1e-3 * kf_average_period << " ms" + << "\n\t\ttotal proc. time: " << 1e-6 * acc_duration_kf_.count() << " s" + << "\n\t\taverage proc. time: " << 1e-3 * acc_duration_kf_.count() / n_kf_callback_ << " ms" + << " (" << average_proc_kf_percent << "%)" + << "\n\t\tmax proc. time: " << 1e-3 * max_duration_kf_.count() << " ms" + << " (" << max_proc_kf_percent << "%)" << std::endl; } bool ProcessorBase::checkTimeTolerance(const TimeStamp& _ts1, const TimeStamp& _ts2) const