aboutsummaryrefslogtreecommitdiffstats
path: root/yardstick/benchmark/scenarios/networking/pktgen.py
diff options
context:
space:
mode:
Diffstat (limited to 'yardstick/benchmark/scenarios/networking/pktgen.py')
-rw-r--r--yardstick/benchmark/scenarios/networking/pktgen.py13
1 files changed, 7 insertions, 6 deletions
diff --git a/yardstick/benchmark/scenarios/networking/pktgen.py b/yardstick/benchmark/scenarios/networking/pktgen.py
index 1e0a5fcbb..a9e7aa6a3 100644
--- a/yardstick/benchmark/scenarios/networking/pktgen.py
+++ b/yardstick/benchmark/scenarios/networking/pktgen.py
@@ -11,6 +11,7 @@ from __future__ import print_function
import os
import logging
+import math
import pkg_resources
from oslo_serialization import jsonutils
@@ -357,15 +358,15 @@ class Pktgen(base.Scenario):
result.update(jsonutils.loads(stdout))
- result['packets_received'] = self._iptables_get_result()
+ received = result['packets_received'] = self._iptables_get_result()
+ sent = result['packets_sent']
result['packetsize'] = packetsize
+ # compatible with python3 /
+ ppm = math.ceil(1000000.0 * (sent - received) / sent)
+
+ result['ppm'] = ppm
if "sla" in self.scenario_cfg:
- sent = result['packets_sent']
- received = result['packets_received']
- ppm = 1000000 * (sent - received) / sent
- # if ppm is 1, then 11 out of 10 million is no pass
- ppm += (sent - received) % sent > 0
LOG.debug("Lost packets %d - Lost ppm %d", (sent - received), ppm)
sla_max_ppm = int(self.scenario_cfg["sla"]["max_ppm"])
assert ppm <= sla_max_ppm, "ppm %d > sla_max_ppm %d; " \