Openembedded Core Discussions
 help / color / mirror / Atom feed
* [PATCHv2] buildstats-summary: round the floating point percentage
@ 2016-07-01 20:39 Christopher Larson
  2016-07-01 20:43 ` Christopher Larson
  0 siblings, 1 reply; 3+ messages in thread
From: Christopher Larson @ 2016-07-01 20:39 UTC (permalink / raw)
  To: openembedded-core; +Cc: Christopher Larson

From: Christopher Larson <chris_larson@mentor.com>

This was rounded in python 2, but python 3 changed the default behavior of /.
We could switch to the same behavior as previous by switching to // rather
than /, but there's value in keeping at least one decimal point, to avoid the
misleading case where it says 0% but the reuse is non-zero.

Signed-off-by: Christopher Larson <chris_larson@mentor.com>
---
 meta/classes/buildstats-summary.bbclass | 6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)

diff --git a/meta/classes/buildstats-summary.bbclass b/meta/classes/buildstats-summary.bbclass
index d73350b..b86abcc 100644
--- a/meta/classes/buildstats-summary.bbclass
+++ b/meta/classes/buildstats-summary.bbclass
@@ -30,7 +30,11 @@ python buildstats_summary () {
                 header_printed = True
                 bb.note("Build completion summary:")
 
-            bb.note("  {0}: {1}% sstate reuse ({2} setscene, {3} scratch)".format(t, 100*len(sstate)/(len(sstate)+len(no_sstate)), len(sstate), len(no_sstate)))
+            sstate_count = len(sstate)
+            no_sstate_count = len(no_sstate)
+            total_count = sstate_count + no_sstate_count
+            bb.note("  {0}: {1:.1f}% sstate reuse({2} setscene, {3} scratch)".format(
+                t, round(100 * sstate_count / total_count, 1), sstate_count, no_sstate_count))
 }
 addhandler buildstats_summary
 buildstats_summary[eventmask] = "bb.event.BuildCompleted"
-- 
2.8.0



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

* [PATCHv2] buildstats-summary: round the floating point percentage
@ 2016-07-01 20:42 Christopher Larson
  0 siblings, 0 replies; 3+ messages in thread
From: Christopher Larson @ 2016-07-01 20:42 UTC (permalink / raw)
  To: openembedded-core; +Cc: Christopher Larson

From: Christopher Larson <chris_larson@mentor.com>

This was rounded in python 2, but python 3 changed the default behavior of /.
We could switch to the same behavior as previous by switching to // rather
than /, but there's value in keeping at least one decimal point, to avoid the
misleading case where it says 0% but the reuse is non-zero.

Signed-off-by: Christopher Larson <chris_larson@mentor.com>
---
 meta/classes/buildstats-summary.bbclass | 6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)

diff --git a/meta/classes/buildstats-summary.bbclass b/meta/classes/buildstats-summary.bbclass
index d73350b..b86abcc 100644
--- a/meta/classes/buildstats-summary.bbclass
+++ b/meta/classes/buildstats-summary.bbclass
@@ -30,7 +30,11 @@ python buildstats_summary () {
                 header_printed = True
                 bb.note("Build completion summary:")
 
-            bb.note("  {0}: {1}% sstate reuse ({2} setscene, {3} scratch)".format(t, 100*len(sstate)/(len(sstate)+len(no_sstate)), len(sstate), len(no_sstate)))
+            sstate_count = len(sstate)
+            no_sstate_count = len(no_sstate)
+            total_count = sstate_count + no_sstate_count
+            bb.note("  {0}: {1:.1f}% sstate reuse({2} setscene, {3} scratch)".format(
+                t, round(100 * sstate_count / total_count, 1), sstate_count, no_sstate_count))
 }
 addhandler buildstats_summary
 buildstats_summary[eventmask] = "bb.event.BuildCompleted"
-- 
2.8.0



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

* Re: [PATCHv2] buildstats-summary: round the floating point percentage
  2016-07-01 20:39 [PATCHv2] buildstats-summary: round the floating point percentage Christopher Larson
@ 2016-07-01 20:43 ` Christopher Larson
  0 siblings, 0 replies; 3+ messages in thread
From: Christopher Larson @ 2016-07-01 20:43 UTC (permalink / raw)
  To: Patches and discussions about the oe-core layer; +Cc: Christopher Larson

[-- Attachment #1: Type: text/plain, Size: 761 bytes --]

On Fri, Jul 1, 2016 at 1:39 PM, Christopher Larson <kergoth@gmail.com>
wrote:

> From: Christopher Larson <chris_larson@mentor.com>
>
> This was rounded in python 2, but python 3 changed the default behavior of
> /.
> We could switch to the same behavior as previous by switching to // rather
> than /, but there's value in keeping at least one decimal point, to avoid
> the
> misleading case where it says 0% but the reuse is non-zero.
>
> Signed-off-by: Christopher Larson <chris_larson@mentor.com>
>

v2 changes: fixed to correctly do the rounding as part of the string
formatting.
-- 
Christopher Larson
kergoth at gmail dot com
Founder - BitBake, OpenEmbedded, OpenZaurus
Maintainer - Tslib
Senior Software Engineer, Mentor Graphics

[-- Attachment #2: Type: text/html, Size: 1315 bytes --]

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

end of thread, other threads:[~2016-07-01 20:43 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2016-07-01 20:39 [PATCHv2] buildstats-summary: round the floating point percentage Christopher Larson
2016-07-01 20:43 ` Christopher Larson
  -- strict thread matches above, loose matches on Subject: below --
2016-07-01 20:42 Christopher Larson

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox