Adjust tsc calculation
Since we only want to record the time when benchmarking
This commit is contained in:
parent
9ba2bbe8cd
commit
2732383465
@ -49,8 +49,10 @@ pub fn analyze_dump(
|
||||
let f_bus = cpuid!(0x16).ecx as f64 * 1_000_000.0;
|
||||
let mut current_cbr = 0u8;
|
||||
|
||||
let mut first_tsc = None::<u64>;
|
||||
let mut last_tsc = 0;
|
||||
// Records the first tsc after the ptwrite (42) message
|
||||
let mut first_tsc_main = None::<u64>;
|
||||
// Records the first tsc after the ptwrite (43) message
|
||||
let mut first_tsc_post_run = None::<u64>;
|
||||
|
||||
let mut seen_cbrs = HashMap::<u8, u64>::new();
|
||||
|
||||
@ -68,10 +70,15 @@ pub fn analyze_dump(
|
||||
segments.last_mut().unwrap().1 += duration;
|
||||
}
|
||||
Ok(Packet::Tsc(tsc)) => {
|
||||
if first_tsc.is_none() {
|
||||
first_tsc = Some(tsc.tsc());
|
||||
if let [.., (Scope::Main, _)] = segments.as_slice()
|
||||
&& first_tsc_main.is_none()
|
||||
{
|
||||
first_tsc_main = Some(tsc.tsc());
|
||||
} else if let [.., (Scope::PostRun, _)] = segments.as_slice()
|
||||
&& first_tsc_post_run.is_none()
|
||||
{
|
||||
first_tsc_post_run = Some(tsc.tsc());
|
||||
}
|
||||
last_tsc = tsc.tsc();
|
||||
}
|
||||
Ok(Packet::Cbr(cbr)) => {
|
||||
current_cbr = cbr.ratio();
|
||||
@ -104,7 +111,7 @@ pub fn analyze_dump(
|
||||
.unwrap()
|
||||
.tsc_frequency()
|
||||
.unwrap();
|
||||
let total_seconds_tsc = (last_tsc - first_tsc.unwrap()) as f64 / f_tsc as f64;
|
||||
let total_seconds_tsc = (first_tsc_post_run.unwrap() - first_tsc_main.unwrap()) as f64 / f_tsc as f64;
|
||||
|
||||
Ok(AnalyzeData {
|
||||
packets: total,
|
||||
|
Loading…
x
Reference in New Issue
Block a user