Track time in main and time disabled
This commit is contained in:
parent
109091c087
commit
2e5af76dbb
@ -11,11 +11,13 @@ pub struct AnalyzeData {
|
|||||||
pub packets: u64,
|
pub packets: u64,
|
||||||
pub cycles: u64,
|
pub cycles: u64,
|
||||||
pub time: Duration,
|
pub time: Duration,
|
||||||
pub time_outside_hypervisor: Duration,
|
pub time_main: Duration,
|
||||||
|
pub time_disabled: Duration,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Debug)]
|
#[derive(Debug, Eq, PartialEq)]
|
||||||
enum Scope {
|
enum Scope {
|
||||||
|
Disabled,
|
||||||
Main,
|
Main,
|
||||||
PreRun,
|
PreRun,
|
||||||
PostRun,
|
PostRun,
|
||||||
@ -42,8 +44,11 @@ pub fn analyze_dump(path: impl AsRef<Path>) -> Result<AnalyzeData, Box<dyn Error
|
|||||||
Ok(Packet::Cyc(cyc)) => {
|
Ok(Packet::Cyc(cyc)) => {
|
||||||
segments.last_mut().unwrap().1 += cyc.value();
|
segments.last_mut().unwrap().1 += cyc.value();
|
||||||
}
|
}
|
||||||
Ok(Packet::Vmcs(_)) => {
|
Ok(Packet::TipPge(_)) => {
|
||||||
// last_packet_vmcs = true;
|
segments.push((Scope::Main, 0));
|
||||||
|
}
|
||||||
|
Ok(Packet::TipPgd(_)) => {
|
||||||
|
segments.push((Scope::Disabled, 0));
|
||||||
}
|
}
|
||||||
Ok(Packet::Ptw(ptwrite)) => {
|
Ok(Packet::Ptw(ptwrite)) => {
|
||||||
if ptwrite.payload() == 42 {
|
if ptwrite.payload() == 42 {
|
||||||
@ -61,18 +66,27 @@ pub fn analyze_dump(path: impl AsRef<Path>) -> Result<AnalyzeData, Box<dyn Error
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
// dbg!(&segments);
|
// dbg!(&segments);
|
||||||
let cycles_main: u64 = segments
|
|
||||||
.iter()
|
|
||||||
.filter(|(scope, _)| matches!(scope, Scope::Main))
|
|
||||||
.map(|(_, cycles)| cycles)
|
|
||||||
.sum();
|
|
||||||
let cycles_total = segments.iter().map(|(_, cycles)| cycles).sum();
|
let cycles_total = segments.iter().map(|(_, cycles)| cycles).sum();
|
||||||
let total_seconds = cycles_total as f64 / 2_700_000_000.0;
|
let total_seconds = cycles_total as f64 / 2_700_000_000.0;
|
||||||
let total_seconds_no_hypervisor = cycles_main as f64 / 2_700_000_000.0;
|
|
||||||
|
let main_duration = duration_in_mode(&segments, Scope::Main);
|
||||||
|
let disabled_duration = duration_in_mode(&segments, Scope::Disabled);
|
||||||
|
|
||||||
Ok(AnalyzeData {
|
Ok(AnalyzeData {
|
||||||
packets: total,
|
packets: total,
|
||||||
cycles: cycles_total,
|
cycles: cycles_total,
|
||||||
time: Duration::from_secs_f64(total_seconds),
|
time: Duration::from_secs_f64(total_seconds),
|
||||||
time_outside_hypervisor: Duration::from_secs_f64(total_seconds_no_hypervisor),
|
time_main: main_duration,
|
||||||
|
time_disabled: disabled_duration
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fn duration_in_mode(segments: &[(Scope, u64)], scope: Scope) -> Duration {
|
||||||
|
let total_cycles = segments
|
||||||
|
.into_iter()
|
||||||
|
.filter(|(it, _)| *it == scope)
|
||||||
|
.map(|(_, cycles)| *cycles)
|
||||||
|
.sum::<u64>();
|
||||||
|
let total_seconds = total_cycles as f64 / 2_700_000_000.0;
|
||||||
|
Duration::from_secs_f64(total_seconds)
|
||||||
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user