MCPcopy Create free account
hub / github.com/PHPantom-dev/phpantom_lsp / sample_rss

Function sample_rss

benches/memory_usage.py:424–439  ·  view source on GitHub ↗

Take multiple RSS samples and return the median (KiB).

(
    pid: int,
    samples: int = RSS_SAMPLES,
    interval: float = RSS_SAMPLE_INTERVAL,
)

Source from the content-addressed store, hash-verified

422
423
424def sample_rss(
425 pid: int,
426 samples: int = RSS_SAMPLES,
427 interval: float = RSS_SAMPLE_INTERVAL,
428) -> int:
429 """Take multiple RSS samples and return the median (KiB)."""
430 values: list[int] = []
431 for _ in range(samples):
432 rss = get_rss_kib(pid)
433 if rss is not None:
434 values.append(rss)
435 time.sleep(interval)
436 if not values:
437 raise RuntimeError(f"Could not read RSS for PID {pid}")
438 values.sort()
439 return values[len(values) // 2]
440
441
442# ── Scenario runners ─────────────────────────────────────────────────────────

Callers 2

run_hello_worldFunction · 0.85
run_laravel_modelFunction · 0.85

Calls 1

get_rss_kibFunction · 0.85

Tested by

no test coverage detected