diff mbox series

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

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

Commit Message

Livius Jan. 25, 2025, 12:27 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=EeDpWoJlUfOYj/cha3GH0X2emMJbKr/wz+vZNdj7owE=;

	b=OPO6nQCAyPkZUyRK1m6d71y54qVAwi2ooND0ti/xpzckENh6iattrWvntnPmYfAz

	J/9lZevOWbGB+QXm0+SeoUpEPS/yKvbU8Bhd/cxzlfTw3MLZrjGGB/oPtMY0A6goevt

	08wfvI/vTnmD/p71OZpd+NXEh0RoF+UsDgn6cS0T0jm59vfSU4mwvdUuyUM4a5lY4tl

	7QpjUUomiAfSf0nRQobgBJg3nWKyE4x/NfUnRV3LseVzrclwWLs7NCUhK0HNT0mEpam

	EJaenUJCZSHJF+CLsTjIIgdoHmmjdJO5u0Vm6rmcgf4NloSGHFdArwenuOKPxf4qfDg

	hIJUM/xJOQ==
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):
@@ -379,13 +380,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:
@@ -398,11 +398,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 bef45cad6..492ea2076 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()