1
0
mirror of https://git.yoctoproject.org/poky synced 2026-07-17 04:07:06 +00:00

bitbake: cooker/process/utils: Create profiling common function to remove code duplication

We have code duplication in the way we handle profiling of code sections.
Create a common function in utils which covers this.

The main loop and idle loop profile files were also reversed. Fix this and the naming,
removing a couple of unused variables containing the profile log names in the process too.

(Bitbake rev: b4f6bae97ac9607420fc49fd4c9e957d89c9a5f3)

Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
This commit is contained in:
Richard Purdie
2025-07-16 15:56:38 +01:00
parent 6933d4b57e
commit e16dd31445
3 changed files with 31 additions and 49 deletions
+2 -34
View File
@@ -80,9 +80,6 @@ class idleFinish():
self.msg = msg
class ProcessServer():
profile_filename = "profile.log"
profile_processed_filename = "profile.log.processed"
def __init__(self, lock, lockname, sock, sockname, server_timeout, xmlrpcinterface):
self.command_channel = False
self.command_channel_reply = False
@@ -140,23 +137,7 @@ class ProcessServer():
serverlog("Error writing to lock file: %s" % str(e))
pass
if self.cooker.configuration.profile:
try:
import cProfile as profile
except:
import profile
prof = profile.Profile()
ret = profile.Profile.runcall(prof, self.main)
prof.dump_stats("profile.log")
bb.utils.process_profilelog("profile.log")
serverlog("Raw profiling information saved to profile.log and processed statistics to profile.log.processed")
else:
ret = self.main()
return ret
return bb.utils.profile_function(self.cooker.configuration.profile, self.main, "profile-mainloop.log")
def _idle_check(self):
return len(self._idlefuns) == 0 and self.cooker.command.currentAsyncCommand is None
@@ -417,20 +398,7 @@ class ProcessServer():
serverlog("".join(msg))
def idle_thread(self):
if self.cooker.configuration.profile:
try:
import cProfile as profile
except:
import profile
prof = profile.Profile()
ret = profile.Profile.runcall(prof, self.idle_thread_internal)
prof.dump_stats("profile-mainloop.log")
bb.utils.process_profilelog("profile-mainloop.log")
serverlog("Raw profiling information saved to profile-mainloop.log and processed statistics to profile-mainloop.log.processed")
else:
self.idle_thread_internal()
bb.utils.profile_function(self.cooker.configuration.profile, self.idle_thread_internal, "profile-idleloop.log")
def idle_thread_internal(self):
def remove_idle_func(function):