Show More
@@ -139,7 +139,7 skips = {"util.py:check", "extensions.py | |||
|
139 | 139 | |
|
140 | 140 | def clock(): |
|
141 | 141 | times = os.times() |
|
142 | return times[0] + times[1] | |
|
142 | return (times[0] + times[1], times[4]) | |
|
143 | 143 | |
|
144 | 144 | |
|
145 | 145 | ########################################################################### |
@@ -151,7 +151,7 class ProfileState(object): | |||
|
151 | 151 | |
|
152 | 152 | def reset(self, frequency=None): |
|
153 | 153 | # total so far |
|
154 | self.accumulated_time = 0.0 | |
|
154 | self.accumulated_time = (0.0, 0.0) | |
|
155 | 155 | # start_time when timer is active |
|
156 | 156 | self.last_start_time = None |
|
157 | 157 | # a float |
@@ -170,10 +170,17 class ProfileState(object): | |||
|
170 | 170 | self.samples = [] |
|
171 | 171 | |
|
172 | 172 | def accumulate_time(self, stop_time): |
|
173 | self.accumulated_time += stop_time - self.last_start_time | |
|
173 | increment = ( | |
|
174 | stop_time[0] - self.last_start_time[0], | |
|
175 | stop_time[1] - self.last_start_time[1], | |
|
176 | ) | |
|
177 | self.accumulated_time = ( | |
|
178 | self.accumulated_time[0] + increment[0], | |
|
179 | self.accumulated_time[1] + increment[1], | |
|
180 | ) | |
|
174 | 181 | |
|
175 | 182 | def seconds_per_sample(self): |
|
176 | return self.accumulated_time / len(self.samples) | |
|
183 | return self.accumulated_time[0] / len(self.samples) | |
|
177 | 184 | |
|
178 | 185 | state = ProfileState() |
|
179 | 186 | |
@@ -261,7 +268,7 def profile_signal_handler(signum, frame | |||
|
261 | 268 | now = clock() |
|
262 | 269 | state.accumulate_time(now) |
|
263 | 270 | |
|
264 | state.samples.append(Sample.from_frame(frame, state.accumulated_time)) | |
|
271 | state.samples.append(Sample.from_frame(frame, state.accumulated_time[0])) | |
|
265 | 272 | |
|
266 | 273 | signal.setitimer(signal.ITIMER_PROF, |
|
267 | 274 | state.sample_interval, 0.0) |
@@ -274,7 +281,7 def samplerthread(tid): | |||
|
274 | 281 | state.accumulate_time(now) |
|
275 | 282 | |
|
276 | 283 | frame = sys._current_frames()[tid] |
|
277 | state.samples.append(Sample.from_frame(frame, state.accumulated_time)) | |
|
284 | state.samples.append(Sample.from_frame(frame, state.accumulated_time[0])) | |
|
278 | 285 | |
|
279 | 286 | state.last_start_time = now |
|
280 | 287 | time.sleep(state.sample_interval) |
@@ -465,7 +472,8 def display(fp=None, format=3, data=None | |||
|
465 | 472 | if format not in (DisplayFormats.Json, DisplayFormats.Chrome): |
|
466 | 473 | print('---', file=fp) |
|
467 | 474 | print('Sample count: %d' % len(data.samples), file=fp) |
|
468 |
print('Total time: %f seconds' % data.accumulated_time, |
|
|
475 | print('Total time: %f seconds (%f wall)' % data.accumulated_time, | |
|
476 | file=fp) | |
|
469 | 477 | |
|
470 | 478 | def display_by_line(data, fp): |
|
471 | 479 | '''Print the profiler data with each sample line represented |
General Comments 0
You need to be logged in to leave comments.
Login now