Loading buildstream/_profile.py +14 −2 Original line number Original line Diff line number Diff line Loading @@ -67,10 +67,19 @@ class Profile(): filename = self.key.replace('/', '-') filename = self.key.replace('/', '-') filename = filename.replace('.', '-') filename = filename.replace('.', '-') filename = os.path.join(os.getcwd(), 'profile-' + timestamp + '-' + filename + '.log') filename = os.path.join(os.getcwd(), 'profile-' + timestamp + '-' + filename) time_ = dt.strftime('%Y-%m-%d %H:%M:%S') # Human friendly format self.__write_log(filename + '.log', time_) self.__write_binary(filename + '.cprofile') ######################################## # Private Methods # ######################################## def __write_log(self, filename, time_): with open(filename, "a", encoding="utf-8") as f: with open(filename, "a", encoding="utf-8") as f: time_ = dt.strftime('%Y-%m-%d %H:%M:%S') heading = '================================================================\n' heading = '================================================================\n' heading += 'Profile for key: {}\n'.format(self.key) heading += 'Profile for key: {}\n'.format(self.key) heading += 'Started at: {}\n'.format(time_) heading += 'Started at: {}\n'.format(time_) Loading @@ -81,6 +90,9 @@ class Profile(): ps = pstats.Stats(self.profiler, stream=f).sort_stats('cumulative') ps = pstats.Stats(self.profiler, stream=f).sort_stats('cumulative') ps.print_stats() ps.print_stats() def __write_binary(self, filename): self.profiler.dump_stats(filename) # profile_start() # profile_start() # # Loading Loading
buildstream/_profile.py +14 −2 Original line number Original line Diff line number Diff line Loading @@ -67,10 +67,19 @@ class Profile(): filename = self.key.replace('/', '-') filename = self.key.replace('/', '-') filename = filename.replace('.', '-') filename = filename.replace('.', '-') filename = os.path.join(os.getcwd(), 'profile-' + timestamp + '-' + filename + '.log') filename = os.path.join(os.getcwd(), 'profile-' + timestamp + '-' + filename) time_ = dt.strftime('%Y-%m-%d %H:%M:%S') # Human friendly format self.__write_log(filename + '.log', time_) self.__write_binary(filename + '.cprofile') ######################################## # Private Methods # ######################################## def __write_log(self, filename, time_): with open(filename, "a", encoding="utf-8") as f: with open(filename, "a", encoding="utf-8") as f: time_ = dt.strftime('%Y-%m-%d %H:%M:%S') heading = '================================================================\n' heading = '================================================================\n' heading += 'Profile for key: {}\n'.format(self.key) heading += 'Profile for key: {}\n'.format(self.key) heading += 'Started at: {}\n'.format(time_) heading += 'Started at: {}\n'.format(time_) Loading @@ -81,6 +90,9 @@ class Profile(): ps = pstats.Stats(self.profiler, stream=f).sort_stats('cumulative') ps = pstats.Stats(self.profiler, stream=f).sort_stats('cumulative') ps.print_stats() ps.print_stats() def __write_binary(self, filename): self.profiler.dump_stats(filename) # profile_start() # profile_start() # # Loading