(self, timer=None, bias=None)
| 151 | bias = 0 # calibration constant |
| 152 | |
| 153 | def __init__(self, timer=None, bias=None): |
| 154 | self.timings = {} |
| 155 | self.cur = None |
| 156 | self.cmd = "" |
| 157 | self.c_func_name = "" |
| 158 | |
| 159 | if bias is None: |
| 160 | bias = self.bias |
| 161 | self.bias = bias # Materialize in local dict for lookup speed. |
| 162 | |
| 163 | if not timer: |
| 164 | self.timer = self.get_time = time.process_time |
| 165 | self.dispatcher = self.trace_dispatch_i |
| 166 | else: |
| 167 | self.timer = timer |
| 168 | t = self.timer() # test out timer function |
| 169 | try: |
| 170 | length = len(t) |
| 171 | except TypeError: |
| 172 | self.get_time = timer |
| 173 | self.dispatcher = self.trace_dispatch_i |
| 174 | else: |
| 175 | if length == 2: |
| 176 | self.dispatcher = self.trace_dispatch |
| 177 | else: |
| 178 | self.dispatcher = self.trace_dispatch_l |
| 179 | # This get_time() implementation needs to be defined |
| 180 | # here to capture the passed-in timer in the parameter |
| 181 | # list (for performance). Note that we can't assume |
| 182 | # the timer() result contains two values in all |
| 183 | # cases. |
| 184 | def get_time_timer(timer=timer, sum=sum): |
| 185 | return sum(timer()) |
| 186 | self.get_time = get_time_timer |
| 187 | self.t = self.get_time() |
| 188 | self.simulate_call('profiler') |
| 189 | |
| 190 | # Heavily optimized dispatch routine for time.process_time() timer |
| 191 |
nothing calls this directly
no test coverage detected