summaryrefslogtreecommitdiff
path: root/tools
diff options
context:
space:
mode:
authorShannon Zhao <zhaoshenglong@huawei.com>2014-06-18 12:18:15 +0800
committerThomas Monjalon <thomas.monjalon@6wind.com>2014-06-19 00:57:50 +0200
commitf1445721a98e6204a0e441a08d582cfe9e1843df (patch)
tree81db83e8ef9eceab11b6f126c2092909ea8c6d8c /tools
parenteb6a0b950edbc95689a50283d44862400207518c (diff)
downloaddpdk-f1445721a98e6204a0e441a08d582cfe9e1843df.zip
dpdk-f1445721a98e6204a0e441a08d582cfe9e1843df.tar.gz
dpdk-f1445721a98e6204a0e441a08d582cfe9e1843df.tar.xz
tools: fix alignment of cpu layout output
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@huawei.com> Acked-by: Pablo de Lara <pablo.de.lara.guarch@intel.com>
Diffstat (limited to 'tools')
-rwxr-xr-xtools/cpu_layout.py18
1 files changed, 12 insertions, 6 deletions
diff --git a/tools/cpu_layout.py b/tools/cpu_layout.py
index 623fad9..20a409d 100755
--- a/tools/cpu_layout.py
+++ b/tools/cpu_layout.py
@@ -75,15 +75,21 @@ 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 + len('[, ]') + len('Socket ')
+max_core_id_len = len(str(max(cores)))
+
+print " ".ljust(max_core_id_len + len('Core ')),
for s in sockets:
- print "\tSocket %s" % s,
+ print "Socket %s" % str(s).ljust(max_core_map_len - len('Socket ')),
print ""
+print " ".ljust(max_core_id_len + len('Core ')),
for s in sockets:
- print "\t---------",
+ print "--------".ljust(max_core_map_len),
print ""
for c in cores:
- print "Core %s" % c,
- for s in sockets:
- print "\t", core_map[(s,c)],
- print "\n"
+ print "Core %s" % str(c).ljust(max_core_id_len),
+ for s in sockets:
+ print str(core_map[(s,c)]).ljust(max_core_map_len),
+ print "\n"