DPDK patches and discussions
 help / color / mirror / Atom feed
From: Shannon Zhao <zhaoshenglong@huawei.com>
To: <dev@dpdk.org>
Subject: [dpdk-dev] [PATCH v3] cpu_layout.py: adjust output format to align
Date: Wed, 18 Jun 2014 12:18:15 +0800	[thread overview]
Message-ID: <1403065095-11092-1-git-send-email-zhaoshenglong@huawei.com> (raw)
In-Reply-To: <2140757.fj3Ic02JMu@xps13>

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>
---
 tools/cpu_layout.py | 18 ++++++++++++------
 1 file 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"
-- 
1.9.0.msysgit.0

  parent reply	other threads:[~2014-06-18  4:19 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-05-29  6:24 [dpdk-dev] [PATCH v2] " Shannon Zhao
2014-05-29  7:22 ` Thomas Monjalon
2014-05-29  7:48   ` Shannon Zhao
2014-06-18  4:18   ` Shannon Zhao [this message]
2014-06-18 18:17     ` [dpdk-dev] [PATCH v3] " De Lara Guarch, Pablo
2014-06-18 23:03       ` Thomas Monjalon
2014-05-29  8:19 Shannon Zhao

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1403065095-11092-1-git-send-email-zhaoshenglong@huawei.com \
    --to=zhaoshenglong@huawei.com \
    --cc=dev@dpdk.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).