Commit 3e6ed8d5 authored by Marcin Siodelski's avatar Marcin Siodelski

[1959] Print overall rate statistics.

parent fbbae39a
......@@ -775,7 +775,8 @@ public:
StatsMgr(const bool archive_enabled = false) :
exchanges_(),
custom_counters_(),
archive_enabled_(archive_enabled) {
archive_enabled_(archive_enabled),
boot_time_(boost::posix_time::microsec_clock::universal_time()) {
}
/// \brief Specify new exchange type.
......@@ -1028,6 +1029,20 @@ public:
return(xchg_stats->getDroppedPacketsNum());
}
/// \brief Get time period since the start of test.
///
/// Calculate dna return period since the test start. This
/// can be specifically helpful when calculating packet
/// exchange rates.
///
/// \return test period so far.
boost::posix_time::time_period getTestPeriod() const {
using namespace boost::posix_time;
time_period test_period(boot_time_,
microsec_clock::universal_time());
return test_period;
}
/// \brief Return name of the exchange.
///
/// Method returns name of the specified exchange type.
......@@ -1158,6 +1173,8 @@ private:
/// for extended period of time and many packets have to be
/// archived.
bool archive_enabled_;
boost::posix_time::ptime boot_time_; ///< Time when test is started.
};
} // namespace perfdhcp
......
......@@ -480,8 +480,31 @@ TestControl::openSocket(uint16_t port) const {
return(sock);
}
void
TestControl::printRate() const {
double rate = 0;
CommandOptions& options = CommandOptions::instance();
if (options.getIpVersion() == 4) {
double duration =
stats_mgr4_->getTestPeriod().length().total_nanoseconds() / 1e9;
rate = stats_mgr4_->getRcvdPacketsNum(StatsMgr4::XCHG_DO) / duration;
} else if (options.getIpVersion() == 6) {
double duration =
stats_mgr6_->getTestPeriod().length().total_nanoseconds() / 1e9;
rate = stats_mgr6_->getRcvdPacketsNum(StatsMgr6::XCHG_SA) / duration;
}
std::cout << "***Rate statistics***" << std::endl;
if (options.getRate() > 0) {
std::cout << "Rate: " << rate << ", expected rate: "
<< options.getRate() << std::endl << std::endl;
} else {
std::cout << "Rate: " << rate << std::endl << std::endl;
}
}
void
TestControl::printStats() const {
printRate();
CommandOptions& options = CommandOptions::instance();
if (options.getIpVersion() == 4) {
if (!stats_mgr4_) {
......
......@@ -360,6 +360,11 @@ protected:
/// \return socket descriptor.
int openSocket(uint16_t port = 0) const;
/// \brief Print rate statistics.
///
/// Method print packet exchange rate statistics.
void printRate() const;
/// \brief Print performance statistics.
///
/// Method prints performance statistics.
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment