def test100ms(self): setstatprofile(self.profile_callback, 0.1) busy_wait(1.0) setstatprofile(None) # check that the profiling calls were throttled appropriately self.assertTrue(8 < self.count < 12, 'profile count should be approx. 10, was %i' % self.count)
def start(self, caller_frame=None): self.last_profile_time = timer() self._start_time = time.time() if process_time: self._start_process_time = process_time() if caller_frame is None: caller_frame = inspect.currentframe().f_back self._start_call_stack = self._call_stack_for_frame(caller_frame) setstatprofile(self._profile, self.interval)
def start(self, caller_frame=None): self.last_profile_time = timer() self._start_time = time.time() if process_time: self._start_process_time = process_time() if caller_frame is None: caller_frame = inspect.currentframe().f_back self._start_call_stack = self._call_stack_for_frame(caller_frame) if sys.getprofile() is not None: raise RuntimeError( 'A profiler is already running. Running multiple profilers on the same thead is not supported.' ) setstatprofile(self._profile, self.interval)
def stop(self): setstatprofile(None) if process_time: cpu_time = process_time() - self._start_process_time self._start_process_time = None else: cpu_time = None self.last_session = ProfilerSession( frame_records=self.frame_records, start_time=self._start_time, duration=time.time() - self._start_time, sample_count=len(self.frame_records), program=' '.join(sys.argv), start_call_stack=self._start_call_stack, cpu_time=cpu_time, ) return self.last_session
def stop(self): setstatprofile(None)
def start(self): self.last_profile_time = timer() setstatprofile(self._profile, self.interval)
def profile_a_busy_wait(self): setstatprofile(self.profile_callback, 0.1) busy_wait(1.0) setstatprofile(None)
def test10ms(self): setstatprofile(self.profile_callback, 0.01) busy_wait(1.0) setstatprofile(None) self.assertTrue(95 < self.count < 105, 'profile count should be approx. 100, was %i' % self.count)