papi: refactor set_errors_str
Assuming 2500 50 char lines:
string_concat elapsed: 5.919933e-04
string_join elapsed: 2.830029e-04
string_concat size: 156,312,500
string_join size: 125,000
Type: refactor
Change-Id: I0a400265426bde492e9a651d24996ddcfe954aa1
Signed-off-by: Paul Vinciguerra <pvinci@vinciconsulting.com>
diff --git a/src/vpp-api/python/vpp_papi/vpp_stats.py b/src/vpp-api/python/vpp_papi/vpp_stats.py
index 3638892..eeaa32d 100644
--- a/src/vpp-api/python/vpp_papi/vpp_stats.py
+++ b/src/vpp-api/python/vpp_papi/vpp_stats.py
@@ -292,8 +292,8 @@
def set_errors_str(self):
'''Return all errors counters > 0 pretty printed'''
- s = 'ERRORS:\n'
+ s = ['ERRORS:']
error_counters = self.set_errors()
for k in sorted(error_counters):
- s += '{:<60}{:>10}\n'.format(k, error_counters[k])
- return s
+ s.append('{:<60}{:>10}'.format(k, error_counters[k]))
+ return '%s\n' % '\n'.join(s)