use std::collections::BTreeMap;
use ktstr::ctprof::{CgroupStats, CtprofSnapshot, ThreadState};
use ktstr::metric_types::{CategoricalString, CpuSet};
#[allow(dead_code)]
pub fn make_thread(pcomm: &str, comm: &str) -> ThreadState {
let mut t = ThreadState::default();
t.tid = 1;
t.tgid = 1;
t.pcomm = pcomm.into();
t.comm = comm.into();
t.cgroup = "/".into();
t.policy = CategoricalString("SCHED_OTHER".into());
t.cpu_affinity = CpuSet(vec![0, 1, 2, 3]);
t
}
#[allow(dead_code)]
pub fn snapshot(
threads: Vec<ThreadState>,
cgroup_stats: BTreeMap<String, CgroupStats>,
) -> CtprofSnapshot {
let mut snap = CtprofSnapshot::default();
snap.threads = threads;
snap.cgroup_stats = cgroup_stats;
snap
}
#[allow(dead_code)]
pub fn cgroup_stats_entry(
cpu_usage_usec: u64,
nr_throttled: u64,
throttled_usec: u64,
memory_current: u64,
) -> CgroupStats {
let mut s = CgroupStats::default();
s.cpu.usage_usec = cpu_usage_usec;
s.cpu.nr_throttled = nr_throttled;
s.cpu.throttled_usec = throttled_usec;
s.memory.current = memory_current;
s
}