DPDK patches and discussions
 help / color / mirror / Atom feed
* [dpdk-dev] [PATCH v2] cpu_layout.py: adjust output format to align
@ 2014-05-29  6:24 Shannon Zhao
  2014-05-29  7:22 ` Thomas Monjalon
  0 siblings, 1 reply; 7+ messages in thread
From: Shannon Zhao @ 2014-05-29  6:24 UTC (permalink / raw)
  To: dev

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 | 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

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [dpdk-dev] [PATCH v2] cpu_layout.py: adjust output format to align
  2014-05-29  6:24 [dpdk-dev] [PATCH v2] cpu_layout.py: adjust output format to align Shannon Zhao
@ 2014-05-29  7:22 ` Thomas Monjalon
  2014-05-29  7:48   ` Shannon Zhao
  2014-06-18  4:18   ` [dpdk-dev] [PATCH v3] " Shannon Zhao
  0 siblings, 2 replies; 7+ messages in thread
From: Thomas Monjalon @ 2014-05-29  7:22 UTC (permalink / raw)
  To: Shannon Zhao; +Cc: dev

Hi Shannon,

I feel this version is better but it's really complicated to read.

> +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

This line is not indented as the other ones.

> +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),

Could you replace all these numbers by something meaningful and easier to 
understand?
Example: 5 can be replaced by len('Core ')

Other comment: please add spaces around operators (= + - *).

Thanks
-- 
Thomas

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [dpdk-dev] [PATCH v2] cpu_layout.py: adjust output format to align
  2014-05-29  7:22 ` Thomas Monjalon
@ 2014-05-29  7:48   ` Shannon Zhao
  2014-06-18  4:18   ` [dpdk-dev] [PATCH v3] " Shannon Zhao
  1 sibling, 0 replies; 7+ messages in thread
From: Shannon Zhao @ 2014-05-29  7:48 UTC (permalink / raw)
  To: Thomas Monjalon; +Cc: dev

Hi Thomas,

Thanks for your advice.
I'll modify the patch and send it as 'patch v3' later.

On 2014/5/29 15:22, Thomas Monjalon wrote:
> Hi Shannon,
> 
> I feel this version is better but it's really complicated to read.
> 
>> +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
> 
> This line is not indented as the other ones.
> 
>> +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),
> 
> Could you replace all these numbers by something meaningful and easier to 
> understand?
> Example: 5 can be replaced by len('Core ')
> 
> Other comment: please add spaces around operators (= + - *).
> 
> Thanks
> 

-- 
Shannon

^ permalink raw reply	[flat|nested] 7+ messages in thread

* [dpdk-dev] [PATCH v3] cpu_layout.py: adjust output format to align
  2014-05-29  7:22 ` Thomas Monjalon
  2014-05-29  7:48   ` Shannon Zhao
@ 2014-06-18  4:18   ` Shannon Zhao
  2014-06-18 18:17     ` De Lara Guarch, Pablo
  1 sibling, 1 reply; 7+ messages in thread
From: Shannon Zhao @ 2014-06-18  4:18 UTC (permalink / raw)
  To: dev

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

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [dpdk-dev] [PATCH v3] cpu_layout.py: adjust output format to align
  2014-06-18  4:18   ` [dpdk-dev] [PATCH v3] " Shannon Zhao
@ 2014-06-18 18:17     ` De Lara Guarch, Pablo
  2014-06-18 23:03       ` Thomas Monjalon
  0 siblings, 1 reply; 7+ messages in thread
From: De Lara Guarch, Pablo @ 2014-06-18 18:17 UTC (permalink / raw)
  To: Shannon Zhao, dev

> -----Original Message-----
> From: dev [mailto:dev-bounces@dpdk.org] On Behalf Of Shannon Zhao
> Sent: Wednesday, June 18, 2014 5:18 AM
> To: dev@dpdk.org
> Subject: [dpdk-dev] [PATCH v3] cpu_layout.py: adjust output format to align
> 
> 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>

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [dpdk-dev] [PATCH v3] cpu_layout.py: adjust output format to align
  2014-06-18 18:17     ` De Lara Guarch, Pablo
@ 2014-06-18 23:03       ` Thomas Monjalon
  0 siblings, 0 replies; 7+ messages in thread
From: Thomas Monjalon @ 2014-06-18 23:03 UTC (permalink / raw)
  To: Shannon Zhao; +Cc: dev

> > 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>

Applied for version 1.7.0.

Thanks
-- 
Thomas

^ permalink raw reply	[flat|nested] 7+ messages in thread

* [dpdk-dev] [PATCH v3] cpu_layout.py: adjust output format to align
@ 2014-05-29  8:19 Shannon Zhao
  0 siblings, 0 replies; 7+ messages in thread
From: Shannon Zhao @ 2014-05-29  8:19 UTC (permalink / raw)
  To: dev

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 | 14 ++++++++++----
 1 file changed, 10 insertions(+), 4 deletions(-)

diff --git a/tools/cpu_layout.py b/tools/cpu_layout.py
index 9eff9d7..52d01a8 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,
+	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

^ permalink raw reply	[flat|nested] 7+ messages in thread

end of thread, other threads:[~2014-06-18 23:03 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2014-05-29  6:24 [dpdk-dev] [PATCH v2] cpu_layout.py: adjust output format to align Shannon Zhao
2014-05-29  7:22 ` Thomas Monjalon
2014-05-29  7:48   ` Shannon Zhao
2014-06-18  4:18   ` [dpdk-dev] [PATCH v3] " Shannon Zhao
2014-06-18 18:17     ` De Lara Guarch, Pablo
2014-06-18 23:03       ` Thomas Monjalon
2014-05-29  8:19 Shannon Zhao

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).