diff --git a/src/logservice/logminer/ob_log_miner_logger.cpp b/src/logservice/logminer/ob_log_miner_logger.cpp index cdb3361b38..9e0624cb91 100644 --- a/src/logservice/logminer/ob_log_miner_logger.cpp +++ b/src/logservice/logminer/ob_log_miner_logger.cpp @@ -29,8 +29,15 @@ LogMinerLogger &LogMinerLogger::get_logminer_logger_instance() static LogMinerLogger logger_instance; return logger_instance; } + LogMinerLogger::LogMinerLogger(): - verbose_(false) { memset(pb_str_, '>', sizeof(pb_str_)); } + verbose_(false), + begin_ts_(0), + last_ts_(0), + last_record_num_(0) +{ + memset(pb_str_, '>', sizeof(pb_str_)); +} void LogMinerLogger::log_stdout(const char *format, ...) { @@ -79,8 +86,29 @@ int LogMinerLogger::log_progress(int64_t record_num, int64_t current_ts, int64_t nls_format, 0, time_buf, sizeof(time_buf), pos))) { LOG_WARN("datetime to string failed", K(current_ts), K(LOGMINER_TZ.get_tz_info())); } else { - fprintf(stdout, "\r%s %s %5.1lf%%, written records: %-20jd", time_buf, pb_buf, - progress, record_num); + int64_t current_time = ObTimeUtility::current_time(); + int64_t average_rps = 0; + int64_t current_rps = 0; + int64_t inc_record_num = 0; + if (begin_ts_ == 0) { + begin_ts_ = current_time; + } + if (last_ts_ == 0) { + last_ts_ = current_time; + } + if (current_time - begin_ts_ > 0) { + // calculated in seconds + average_rps = record_num * 1000 * 1000 / (current_time - begin_ts_); + } + if (current_time - last_ts_ > 0) { + inc_record_num = record_num - last_record_num_; + // calculated in seconds + current_rps = inc_record_num * 1000 * 1000 / (current_time - last_ts_); + last_ts_ = current_time; + last_record_num_ = record_num; + } + fprintf(stdout, "\r%s %s %5.1lf%%, written records: %5.1jd, current rps: %5.1jd, average rps: %5.1jd", + time_buf, pb_buf, progress, record_num, current_rps, average_rps); fflush(stdout); } return ret; diff --git a/src/logservice/logminer/ob_log_miner_logger.h b/src/logservice/logminer/ob_log_miner_logger.h index a28d69569d..e83d24a6a9 100644 --- a/src/logservice/logminer/ob_log_miner_logger.h +++ b/src/logservice/logminer/ob_log_miner_logger.h @@ -43,6 +43,9 @@ private: static const int MAX_SCREEN_WIDTH = 4096; bool verbose_; char pb_str_[MAX_SCREEN_WIDTH]; + int64_t begin_ts_; + int64_t last_ts_; + int64_t last_record_num_; }; }