- lat = [int(item) for item in str(groups.group(idx)).split('/')]
- except (AttributeError, ValueError):
- lat = [-1, -1, -1]
- latencies.append(lat)
-
- keys = ("min", "avg", "max")
- latency = {
- "direction1": {
- },
- "direction2": {
- }
- }
-
- latency["direction1"]["100"] = dict(zip(keys, latencies[0]))
- latency["direction2"]["100"] = dict(zip(keys, latencies[1]))
- if test_type == "NDR":
- latency["direction1"]["50"] = dict(zip(keys, latencies[2]))
- latency["direction2"]["50"] = dict(zip(keys, latencies[3]))
- latency["direction1"]["10"] = dict(zip(keys, latencies[4]))
- latency["direction2"]["10"] = dict(zip(keys, latencies[5]))
-
- return latency
+ host = str(re.search(self.REGEX_TC_PAPI_CLI, msg.message).
+ group(1))
+ except (AttributeError, IndexError):
+ host = self._data[u"tests"][self._test_id][u"show-run"].\
+ count(u"DUT:") + 1
+ try:
+ socket = str(re.search(self.REGEX_TC_PAPI_CLI, msg.message).
+ group(2))
+ socket = f"/{socket}"
+ except (AttributeError, IndexError):
+ socket = u""
+ runtime = loads(
+ str(msg.message).
+ replace(u' ', u'').
+ replace(u'\n', u'').
+ replace(u"'", u'"').
+ replace(u'b"', u'"').
+ replace(u'u"', u'"').
+ split(u":", 1)[1]
+ )
+ try:
+ threads_nr = len(runtime[0][u"clocks"])
+ except (IndexError, KeyError):
+ return
+ tbl_hdr = [
+ u"Name",
+ u"Calls",
+ u"Vectors",
+ u"Suspends",
+ u"Clocks",
+ u"Vectors/Calls"
+ ]
+ table = [[tbl_hdr, ] for _ in range(threads_nr)]
+ for item in runtime:
+ for idx in range(threads_nr):
+ name = format(item[u"name"])
+ calls = format(item[u"calls"][idx])
+ vectors = format(item[u"vectors"][idx])
+ suspends = format(item[u"suspends"][idx])
+ if item[u"vectors"][idx] > 0:
+ clocks = format(
+ item[u"clocks"][idx]/item[u"vectors"][idx], u".2e")
+ elif item[u"calls"][idx] > 0:
+ clocks = format(
+ item[u"clocks"][idx]/item[u"calls"][idx], u".2e")
+ elif item[u"suspends"][idx] > 0:
+ clocks = format(
+ item[u"clocks"][idx]/item[u"suspends"][idx], u".2e")
+ else:
+ clocks = 0
+ if item[u"calls"][idx] > 0:
+ vectors_call = format(
+ item[u"vectors"][idx]/item[u"calls"][idx], u".2f")
+ else:
+ vectors_call = format(0, u".2f")
+ if int(calls) + int(vectors) + int(suspends):
+ table[idx].append([
+ name, calls, vectors, suspends, clocks, vectors_call
+ ])
+ text = ""
+ for idx in range(threads_nr):
+ text += f"Thread {idx} "
+ text += u"vpp_main\n" if idx == 0 else f"vpp_wk_{idx-1}\n"
+ txt_table = None
+ for row in table[idx]:
+ if txt_table is None:
+ txt_table = prettytable.PrettyTable(row)
+ else:
+ if any(row[1:]):
+ txt_table.add_row(row)
+ txt_table.set_style(prettytable.MSWORD_FRIENDLY)
+ txt_table.align[u"Name"] = u"l"
+ txt_table.align[u"Calls"] = u"r"
+ txt_table.align[u"Vectors"] = u"r"
+ txt_table.align[u"Suspends"] = u"r"
+ txt_table.align[u"Clocks"] = u"r"
+ txt_table.align[u"Vectors/Calls"] = u"r"
+
+ text += txt_table.get_string(sortby=u"Name") + u'\n'
+ text = f"\n**DUT: {host}{socket}**\n{text}".\
+ replace(u'\n', u' |br| ').\
+ replace(u'\r', u'').\
+ replace(u'"', u"'")
+ self._data[u"tests"][self._test_id][u"show-run"] += text