BIND 10 trac1959, updated. 3e6ed8d54322d7ebeb2721664dd7d2dd8326094a [1959] Print overall rate statistics.

BIND 10 source code commits bind10-changes at lists.isc.org
Tue Aug 21 15:18:56 UTC 2012


The branch, trac1959 has been updated
       via  3e6ed8d54322d7ebeb2721664dd7d2dd8326094a (commit)
      from  fbbae39aea715ccca384083611b6faa8250e068d (commit)

Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.

- Log -----------------------------------------------------------------
commit 3e6ed8d54322d7ebeb2721664dd7d2dd8326094a
Author: Marcin Siodelski <marcin at isc.org>
Date:   Tue Aug 21 17:18:30 2012 +0200

    [1959] Print overall rate statistics.

-----------------------------------------------------------------------

Summary of changes:
 tests/tools/perfdhcp/stats_mgr.h     |   19 ++++++++++++++++++-
 tests/tools/perfdhcp/test_control.cc |   23 +++++++++++++++++++++++
 tests/tools/perfdhcp/test_control.h  |    5 +++++
 3 files changed, 46 insertions(+), 1 deletion(-)

-----------------------------------------------------------------------
diff --git a/tests/tools/perfdhcp/stats_mgr.h b/tests/tools/perfdhcp/stats_mgr.h
index 5a3f114..1e57dda 100644
--- a/tests/tools/perfdhcp/stats_mgr.h
+++ b/tests/tools/perfdhcp/stats_mgr.h
@@ -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
diff --git a/tests/tools/perfdhcp/test_control.cc b/tests/tools/perfdhcp/test_control.cc
index 87b2814..9ba869a 100644
--- a/tests/tools/perfdhcp/test_control.cc
+++ b/tests/tools/perfdhcp/test_control.cc
@@ -481,7 +481,30 @@ TestControl::openSocket(uint16_t port) const {
 }
 
 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_) {
diff --git a/tests/tools/perfdhcp/test_control.h b/tests/tools/perfdhcp/test_control.h
index 1a3157b..a93d05d 100644
--- a/tests/tools/perfdhcp/test_control.h
+++ b/tests/tools/perfdhcp/test_control.h
@@ -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.



More information about the bind10-changes mailing list