diff --git a/pt-dump-decoder/src/lib.rs b/pt-dump-decoder/src/lib.rs index 8538073..09f8000 100644 --- a/pt-dump-decoder/src/lib.rs +++ b/pt-dump-decoder/src/lib.rs @@ -10,14 +10,13 @@ use std::time::Duration; pub struct AnalyzeData { pub packets: u64, pub cycles: u64, - pub time: Duration, + pub time_tsc: Duration, + pub time_cyc: Duration, pub time_main: Duration, - pub time_disabled: Duration, } #[derive(Debug, Eq, PartialEq)] enum Scope { - Disabled, Main, PreRun, PostRun, @@ -38,17 +37,20 @@ pub fn analyze_dump(path: impl AsRef) -> Result; + let mut last_tsc = 0; + for packet in decoder { total += 1; match packet { Ok(Packet::Cyc(cyc)) => { segments.last_mut().unwrap().1 += cyc.value(); } - Ok(Packet::TipPge(_)) => { - segments.push((Scope::Main, 0)); - } - Ok(Packet::TipPgd(_)) => { - segments.push((Scope::Disabled, 0)); + Ok(Packet::Tsc(tsc)) => { + if first_tsc.is_none() { + first_tsc = Some(tsc.tsc()); + } + last_tsc = tsc.tsc(); } Ok(Packet::Ptw(ptwrite)) => { if ptwrite.payload() == 42 { @@ -61,6 +63,9 @@ pub fn analyze_dump(path: impl AsRef) -> Result { + panic!("Got overflow packet: {overflow:?}, index {total}"); + } Ok(_) => {} Err(error) => println!("Got error: {error:?}"), } @@ -69,15 +74,16 @@ pub fn analyze_dump(path: impl AsRef) -> Result