diff mbox series

[v2,4/4] bitbake: knotty: print() was eliminated from all loops for better performance.

Message ID 20250122232411.133-5-egyszeregy@freemail.hu
State New
Headers show
Series bitbake: knotty/progressbar: Optimize footer update and prints. | expand

Commit Message

Livius Jan. 22, 2025, 11:24 p.m. UTC
s=20181004; d=freemail.hu;

	h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References:MIME-Version:Content-Type:Content-Transfer-Encoding;

	l=1871; bh=tOCywO57AdcGssqoQY6VKW8CxCgsY7zpgBWvRbgEBvE=;

	b=AyzBtTiNk9uHQgoYs5u98aWhaXDE/gQykKrohGzF9Pj8oTblLdmIOrdOFsKiN7zV

	cj99R4gYoJNWhukqEJ0e9kPBomBlqyw9ZTxZTfaIZqRl3/6FpnXyKFLnDyXpX/hORQi

	ooBvyovFtrRGXdZdJfMRO3A7Mxdqhexeyci6eoeGAclwaKka3vkW3n5Ujaj449EkRAl

	ET463PuQydDVxmnEiATRCrKQKEaefweFvmDyDnJQsBIIV2HVuDqcG3jpUKReoTzcZCr

	0UAENsHZM7YL/D9tccMFKIROgiZgNsNq9ehcWf/UHKxS6f9hObDz+VmZ0dmduaPOwoA

	4ZS0lWvqkA==
Content-Transfer-Encoding: quoted-printable

From: Benjamin Sz=C5=91ke <egyszeregy@freemail.hu>

Refactoring prints, print() functions were eliminated from all loops and =
it uses
"\n".join(...) in a single print() call for better performance.

Signed-off-by: Benjamin Sz=C5=91ke <egyszeregy@freemail.hu>
---
 lib/bb/ui/knotty.py | 14 +++++++-------
 1 file changed, 7 insertions(+), 7 deletions(-)

=20
     def updateFooter(self):
@@ -378,13 +379,12 @@ class TerminalFilter(object):
             self.termios.tcsetattr(fd, self.termios.TCSADRAIN, self.stdi=
nbackup)
=20
 def print_event_log(event, includelogs, loglines, termfilter):
-    # FIXME refactor this out further
     logfile =3D event.logfile
     if logfile and os.path.exists(logfile):
         termfilter.clearFooter()
         bb.error("Logfile of failure stored in: %s" % logfile)
         if includelogs and not event.errprinted:
-            print("Log data follows:")
+            msgbuf =3D ["Log data follows:"]
             f =3D open(logfile, "r")
             lines =3D []
             while True:
@@ -397,11 +397,11 @@ def print_event_log(event, includelogs, loglines, t=
ermfilter):
                     if len(lines) > int(loglines):
                         lines.pop(0)
                 else:
-                    print('| %s' % l)
+                    msgbuf.append('| %s' % l)
             f.close()
             if lines:
-                for line in lines:
-                    print(line)
+                msgbuf.extend(lines)
+            print("\n".join(msgbuf))
=20
 def _log_settings_from_server(server, observe_only):
     # Get values of variables which control our output
--=20
2.47.1.windows.2
diff mbox series

Patch

diff --git a/lib/bb/ui/knotty.py b/lib/bb/ui/knotty.py
index ad018a182..dfc76483c 100644
--- a/lib/bb/ui/knotty.py
+++ b/lib/bb/ui/knotty.py
@@ -243,9 +243,10 @@  class TerminalFilter(object):
=20
     def keepAlive(self, t):
         if not self.cuu:
-            print("Bitbake still alive (no events for %ds). Active tasks=
:" % t)
+            msgbuf =3D ["Bitbake still alive (no events for %ds). Active=
 tasks:" % t]
             for t in self.helper.running_tasks:
-                print(t)
+                msgbuf.append(str(t))
+            print("\n".join(msgbuf))
             sys.stdout.flush()