memit magic run details. Object based on IPython's TimeitResult
| 60 | |
| 61 | |
| 62 | class MemitResult(object): |
| 63 | """memit magic run details. |
| 64 | |
| 65 | Object based on IPython's TimeitResult |
| 66 | """ |
| 67 | |
| 68 | def __init__(self, mem_usage, baseline, repeat, timeout, interval, |
| 69 | include_children): |
| 70 | self.mem_usage = mem_usage |
| 71 | self.baseline = baseline |
| 72 | self.repeat = repeat |
| 73 | self.timeout = timeout |
| 74 | self.interval = interval |
| 75 | self.include_children = include_children |
| 76 | |
| 77 | def __str__(self): |
| 78 | max_mem = max(self.mem_usage) |
| 79 | inc = max_mem - self.baseline |
| 80 | return 'peak memory: %.02f MiB, increment: %.02f MiB' % (max_mem, inc) |
| 81 | |
| 82 | def _repr_pretty_(self, p, cycle): |
| 83 | msg = str(self) |
| 84 | p.text(u'<MemitResult : ' + msg + u'>') |
| 85 | |
| 86 | |
| 87 | def _get_child_memory(process, meminfo_attr=None, memory_metric=0): |