James Ennis pushed to branch jennis/profiling_outputs_binaries at BuildStream / buildstream
Commits:
-
f64ee46f
by James Ennis at 2019-01-17T17:02:28Z
1 changed file:
Changes:
| ... | ... | @@ -67,10 +67,19 @@ class Profile(): |
| 67 | 67 |
|
| 68 | 68 |
filename = self.key.replace('/', '-')
|
| 69 | 69 |
filename = filename.replace('.', '-')
|
| 70 |
- filename = os.path.join(os.getcwd(), 'profile-' + timestamp + '-' + filename + '.log')
|
|
| 70 |
+ filename = os.path.join(os.getcwd(), 'profile-' + timestamp + '-' + filename)
|
|
| 71 | 71 |
|
| 72 |
+ time_ = dt.strftime('%Y-%m-%d %H:%M:%S') # Human friendly format
|
|
| 73 |
+ self.__write_log(filename + '.log', time_)
|
|
| 74 |
+ |
|
| 75 |
+ self.__write_binary(filename + '.cprofile')
|
|
| 76 |
+ |
|
| 77 |
+ ########################################
|
|
| 78 |
+ # Private Methods #
|
|
| 79 |
+ ########################################
|
|
| 80 |
+ |
|
| 81 |
+ def __write_log(self, filename, time_):
|
|
| 72 | 82 |
with open(filename, "a", encoding="utf-8") as f:
|
| 73 |
- time_ = dt.strftime('%Y-%m-%d %H:%M:%S')
|
|
| 74 | 83 |
heading = '================================================================\n'
|
| 75 | 84 |
heading += 'Profile for key: {}\n'.format(self.key)
|
| 76 | 85 |
heading += 'Started at: {}\n'.format(time_)
|
| ... | ... | @@ -81,6 +90,9 @@ class Profile(): |
| 81 | 90 |
ps = pstats.Stats(self.profiler, stream=f).sort_stats('cumulative')
|
| 82 | 91 |
ps.print_stats()
|
| 83 | 92 |
|
| 93 |
+ def __write_binary(self, filename):
|
|
| 94 |
+ self.profiler.dump_stats(filename)
|
|
| 95 |
+ |
|
| 84 | 96 |
|
| 85 | 97 |
# profile_start()
|
| 86 | 98 |
#
|
