test suite reviews and discussions
 help / color / mirror / Atom feed
From: yufengmx <yufengx.mo@intel.com>
To: dts@dpdk.org, lijuan.tu@intel.com, yingyax.han@intel.com
Cc: yufengmx <yufengx.mo@intel.com>
Subject: [dts] [PATCH V1 1/1] framework/pktgen: add actual line rate return for loss.
Date: Fri, 13 Mar 2020 16:27:03 +0800	[thread overview]
Message-ID: <20200313082703.24868-2-yufengx.mo@intel.com> (raw)
In-Reply-To: <20200313082703.24868-1-yufengx.mo@intel.com>


measure_rfc2544_dichotomy/loss rate add actual line rate return value.

Signed-off-by: yufengmx <yufengx.mo@intel.com>
---
 framework/pktgen_base.py | 47 ++++++++++++++++++++++++++++++----------
 1 file changed, 35 insertions(+), 12 deletions(-)

diff --git a/framework/pktgen_base.py b/framework/pktgen_base.py
index 7e1ff48..bee703e 100644
--- a/framework/pktgen_base.py
+++ b/framework/pktgen_base.py
@@ -263,6 +263,7 @@ class PacketGenerator(object):
         """
         delay = options.get('delay')
         duration = options.get('duration') or 10
+        throughput_stat_flag = options.get('throughput_stat_flag') or False
         self._prepare_transmission(stream_ids=stream_ids)
         # start warm up traffic
         self.__warm_up_pktgen(stream_ids, options, delay)
@@ -270,6 +271,8 @@ class PacketGenerator(object):
         self._start_transmission(stream_ids, options)
         # keep traffic within a duration time
         time.sleep(duration)
+        if throughput_stat_flag:
+            _throughput_stats = self.__get_single_throughput_statistic(stream_ids)
         self._stop_transmission(None)
         result = {}
         used_rx_port = []
@@ -287,7 +290,10 @@ class PacketGenerator(object):
                 if loss_rate < 0:
                     loss_rate = 0
             result[port_id] = (loss_rate, tx_pkts, rx_pkts)
-        return result
+        if throughput_stat_flag:
+            return result, _throughput_stats
+        else:
+            return result
 
     def measure_loss(self, stream_ids=[], options={}):
         '''
@@ -491,6 +497,7 @@ class PacketGenerator(object):
         accuracy = options.get('accuracy') or 0.001
         permit_loss_rate = options.get('pdr') or 0.0
         duration = options.get('duration') or 10.0
+        throughput_stat_flag = options.get('throughput_stat_flag') or False
         # start warm up traffic
         delay = options.get('delay')
         _options = {'duration': duration}
@@ -505,10 +512,14 @@ class PacketGenerator(object):
         traffic_rate_min = min_rate
         while True:
             # run loss rate testing
-            _options = {'duration': duration}
+            _options = {
+                'throughput_stat_flag': throughput_stat_flag,
+                'duration': duration, }
             result = self._measure_loss(stream_ids, _options)
             loss_rate_table.append([rate, result])
-            status = self._check_loss_rate(result, permit_loss_rate)
+            status = self._check_loss_rate(
+                result[0] if throughput_stat_flag else result,
+                permit_loss_rate)
             # if upper bound rate percent hit, quit the left flow
             if rate == max_rate and status:
                 hit_result = result
@@ -528,16 +539,28 @@ class PacketGenerator(object):
             # set stream rate percent to custom value
             self._set_stream_rate_percent(rate)
 
-        if not hit_result:
-            msg = ('expected permit loss rate <{0}> '
-                   'not between rate {1} and rate {2}').format(
-                        permit_loss_rate, max_rate, min_rate)
-            self.logger.error(msg)
-            self.logger.info(pformat(loss_rate_table))
-            ret_value = 0, result[0][1], result[0][2]
+        if throughput_stat_flag:
+            if not hit_result[0]:
+                msg = ('expected permit loss rate <{0}> '
+                       'not between rate {1} and rate {2}').format(
+                            permit_loss_rate, max_rate, min_rate)
+                self.logger.error(msg)
+                self.logger.info(pformat(loss_rate_table))
+                ret_value = 0, result[0][0][1], result[0][0][2], 0
+            else:
+                self.logger.debug(pformat(loss_rate_table))
+                ret_value = rate, hit_result[0][0][1], hit_result[0][0][2], hit_result[1][1]
         else:
-            self.logger.debug(pformat(loss_rate_table))
-            ret_value = rate, hit_result[0][1], hit_result[0][2]
+            if not hit_result:
+                msg = ('expected permit loss rate <{0}> '
+                       'not between rate {1} and rate {2}').format(
+                            permit_loss_rate, max_rate, min_rate)
+                self.logger.error(msg)
+                self.logger.info(pformat(loss_rate_table))
+                ret_value = 0, result[0][1], result[0][2]
+            else:
+                self.logger.debug(pformat(loss_rate_table))
+                ret_value = rate, hit_result[0][1], hit_result[0][2]
         self.logger.info("zero loss rate is %f" % rate)
 
         return ret_value
-- 
2.21.0


  reply	other threads:[~2020-03-13  8:23 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-03-13  8:27 [dts] [PATCH V1 0/1] " yufengmx
2020-03-13  8:27 ` yufengmx [this message]
2020-03-16  2:25 ` Mo, YufengX
2020-03-16  2:28 yufengmx
2020-03-16  2:28 ` [dts] [PATCH V1 1/1] " yufengmx
2020-03-16  2:30   ` Tu, Lijuan
2020-03-16  2:32     ` Mo, YufengX
2020-03-20  8:04   ` Tu, Lijuan

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20200313082703.24868-2-yufengx.mo@intel.com \
    --to=yufengx.mo@intel.com \
    --cc=dts@dpdk.org \
    --cc=lijuan.tu@intel.com \
    --cc=yingyax.han@intel.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).