MCPcopy Create free account
hub / github.com/NativeScript/SimDeck / sample_process

Function sample_process

packages/server/src/performance.rs:447–469  ·  view source on GitHub ↗
(
    process: PerformanceProcess,
    include_network: bool,
)

Source from the content-addressed store, hash-verified

445}
446
447async fn sample_process(
448 process: PerformanceProcess,
449 include_network: bool,
450) -> RawPerformanceSample {
451 let pid = process.pid;
452 let ps = ps_process_for_pid(pid).await;
453 let rusage = read_process_rusage(pid);
454 let network = if include_network {
455 sample_network(pid).await.ok()
456 } else {
457 None
458 };
459 RawPerformanceSample {
460 ps_cpu_percent: ps.as_ref().map_or(0.0, |process| process.cpu_percent),
461 ps_memory_resident_bytes: ps
462 .as_ref()
463 .and_then(|process| process.rss_kb)
464 .map(|rss_kb| rss_kb.saturating_mul(1024)),
465 process,
466 rusage,
467 network,
468 }
469}
470
471async fn list_ps_processes() -> Result<Vec<PsProcess>, AppError> {
472 let output = timeout(

Callers 1

snapshotMethod · 0.85

Calls 3

ps_process_for_pidFunction · 0.85
read_process_rusageFunction · 0.85
sample_networkFunction · 0.85

Tested by

no test coverage detected