(
process: PerformanceProcess,
include_network: bool,
)
| 445 | } |
| 446 | |
| 447 | async 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 | |
| 471 | async fn list_ps_processes() -> Result<Vec<PsProcess>, AppError> { |
| 472 | let output = timeout( |
no test coverage detected