From 10ca8f89f60706240a1dff83c8f1f57018f50bfe Mon Sep 17 00:00:00 2001 From: David Venhoff Date: Thu, 4 Sep 2025 16:31:17 +0200 Subject: [PATCH] Track total time using tsc packets and total internal time with cycles. Something is still wrong though, the tsc time is somehow less than the cyc time --- pt-dump-decoder/src/lib.rs | 28 +++++++++++++++++----------- 1 file changed, 17 insertions(+), 11 deletions(-) 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