Show the used memory (only works for Linux 2.6.x).
(explain: str, tref: float, encoding=None)
| 263 | |
| 264 | |
| 265 | def show_stats(explain: str, tref: float, encoding=None) -> float: |
| 266 | """Show the used memory (only works for Linux 2.6.x).""" |
| 267 | for line in Path("/proc/self/status").read_text().splitlines(): |
| 268 | if line.startswith("VmSize:"): |
| 269 | vmsize = int(line.split()[1]) |
| 270 | elif line.startswith("VmRSS:"): |
| 271 | vmrss = int(line.split()[1]) |
| 272 | elif line.startswith("VmData:"): |
| 273 | vmdata = int(line.split()[1]) |
| 274 | elif line.startswith("VmStk:"): |
| 275 | vmstk = int(line.split()[1]) |
| 276 | elif line.startswith("VmExe:"): |
| 277 | vmexe = int(line.split()[1]) |
| 278 | elif line.startswith("VmLib:"): |
| 279 | vmlib = int(line.split()[1]) |
| 280 | print("Memory usage: ******* %s *******" % explain) |
| 281 | print(f"VmSize: {vmsize:>7} kB\tVmRSS: {vmrss:>7} kB") |
| 282 | print(f"VmData: {vmdata:>7} kB\tVmStk: {vmstk:>7} kB") |
| 283 | print(f"VmExe: {vmexe:>7} kB\tVmLib: {vmlib:>7} kB") |
| 284 | tnow = clock() |
| 285 | print(f"WallClock time: {tnow - tref:.3f}") |
| 286 | return tnow |
| 287 | |
| 288 | |
| 289 | # truncate data before calling __setitem__, to improve compression ratio |
no outgoing calls
no test coverage detected