[dpdk-dev] [PATCH v2] cpu_layout.py: adjust output format to align
Shannon Zhao
zhaoshenglong at huawei.com
Thu May 29 08:24:59 CEST 2014
Bug: when "core id" is greater than 9, the cpu_layout.py output doesn't align.
Socket 0 Socket 1
--------- ---------
Core 9 [4, 16] [10, 22]
Core 10 [5, 17] [11, 23]
Solution: adjust output format to align based on the maximum length of the "core id" and "processor"
Socket 0 Socket 1
--------- ---------
Core 9 [4, 16] [10, 22]
Core 10 [5, 17] [11, 23]
Signed-off-by: Shannon Zhao <zhaoshenglong at huawei.com>
---
tools/cpu_layout.py | 16 ++++++++++++----
1 file changed, 12 insertions(+), 4 deletions(-)
diff --git a/tools/cpu_layout.py b/tools/cpu_layout.py
index 9eff9d7..eeda17e 100755
--- a/tools/cpu_layout.py
+++ b/tools/cpu_layout.py
@@ -75,15 +75,23 @@ print "cores = ",cores
print "sockets = ", sockets
print ""
+max_processor_len=len(str(len(cores)*len(sockets)*2-1))
+max_core_map_len = max_processor_len*2+4
+if max_core_map_len < 12:
+ max_core_map_len = 12
+max_core_id_len=len(str(max(cores)))
+
+print " ".ljust(max_core_id_len+5),
for s in sockets:
- print "\tSocket %s" % s,
+ print "Socket %s" % str(s).ljust(max_core_map_len-7),
print ""
+print " ".ljust(max_core_id_len+5),
for s in sockets:
- print "\t---------",
+ print "---------".ljust(max_core_map_len),
print ""
for c in cores:
- print "Core %s" % c,
+ print "Core %s" % str(c).ljust(max_core_id_len),
for s in sockets:
- print "\t", core_map[(s,c)],
+ print str(core_map[(s,c)]).ljust(max_core_map_len),
print "\n"
--
1.9.0.msysgit.0
More information about the dev
mailing list