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)
예제 #2
0
    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)
예제 #3
0
    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)
예제 #4
0
    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)
예제 #5
0
    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
예제 #6
0
    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
예제 #7
0
 def stop(self):
     setstatprofile(None)
예제 #8
0
 def start(self):
     self.last_profile_time = timer()
     setstatprofile(self._profile, self.interval)
예제 #9
0
 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)