Summary Args: *args (TYPE): Description **kwargs (TYPE): Description Returns: TYPE: Description
(self, *args, **kwargs)
| 42 | self.freq = freq |
| 43 | |
| 44 | def __call__(self, *args, **kwargs): |
| 45 | """Summary |
| 46 | |
| 47 | Args: |
| 48 | *args (TYPE): Description |
| 49 | **kwargs (TYPE): Description |
| 50 | |
| 51 | Returns: |
| 52 | TYPE: Description |
| 53 | """ |
| 54 | start = time.time() |
| 55 | # args contains the caller itself |
| 56 | # print args[0] and you will see |
| 57 | result = self.func(*args, **kwargs) |
| 58 | end = time.time() |
| 59 | |
| 60 | self.call_count += 1 |
| 61 | self.acc_time += (end - start) |
| 62 | if self.call_count > 0 and self.call_count % self.freq == 0: |
| 63 | print("Avg time cost of %s%s is %f", |
| 64 | self.class_name, self.__name__, |
| 65 | self.acc_time / self.call_count) |
| 66 | self.call_count = 0 |
| 67 | self.acc_time = 0.0 |
| 68 | |
| 69 | return result |
| 70 | |
| 71 | def __get__(self, instance, cls): |
| 72 | """Summary |
nothing calls this directly
no outgoing calls
no test coverage detected