Show the used memory (only works for Linux 2.6.x).
(explain, tref)
| 11 | |
| 12 | |
| 13 | def show_stats(explain, tref): |
| 14 | "Show the used memory (only works for Linux 2.6.x)." |
| 15 | for line in Path("/proc/self/status").read_text().splitlines(): |
| 16 | if line.startswith("VmSize:"): |
| 17 | vmsize = int(line.split()[1]) |
| 18 | elif line.startswith("VmRSS:"): |
| 19 | vmrss = int(line.split()[1]) |
| 20 | elif line.startswith("VmData:"): |
| 21 | vmdata = int(line.split()[1]) |
| 22 | elif line.startswith("VmStk:"): |
| 23 | vmstk = int(line.split()[1]) |
| 24 | elif line.startswith("VmExe:"): |
| 25 | vmexe = int(line.split()[1]) |
| 26 | elif line.startswith("VmLib:"): |
| 27 | vmlib = int(line.split()[1]) |
| 28 | print("Memory usage: ******* %s *******" % explain) |
| 29 | print(f"VmSize: {vmsize:>7} kB\tVmRSS: {vmrss:>7} kB") |
| 30 | print(f"VmData: {vmdata:>7} kB\tVmStk: {vmstk:>7} kB") |
| 31 | print(f"VmExe: {vmexe:>7} kB\tVmLib: {vmlib:>7} kB") |
| 32 | tnow = clock() |
| 33 | print(f"WallClock time: {tnow - tref:.3f}") |
| 34 | return tnow |
| 35 | |
| 36 | |
| 37 | def populate(f, nlevels): |