Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

test_get_named_events: Don't try and maintain the set of all possible perf stat keys here. #158

Merged
merged 1 commit into from
Apr 23, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
42 changes: 16 additions & 26 deletions src/data/perf_stat.rs
Original file line number Diff line number Diff line change
Expand Up @@ -595,34 +595,24 @@ mod tests {
let events = PerfStat::new()
.get_data(processed_buffer, "run=test&get=keys".to_string())
.unwrap();
let values: Vec<&str> = serde_json::from_str(&events).unwrap();
let mut key_map = HashMap::new();
let event_names = [
"ipc",
"branch-mpki",
"data-l1-mpki",
"inst-l1-mpki",
"l2-mpki",
"l3-mpki",
"stall-frontend-pkc",
"stall-backend-pkc",
"inst-tlb-mpki",
"inst-tlb-tw-pki",
"data-tlb-mpki",
"data-tlb-tw-pki",
"code-sparsity",
];
for name in event_names {
key_map.insert(name.to_string(), 0);
}
let values: Vec<String> = serde_json::from_str(&events).unwrap();

// Make sure at least ipc was reported (should be present everywhere)
assert!(values.contains(&"ipc".to_owned()));

// Make sure all keys that were reported were returned the same number of
// times (in other words that they were all reported for all CPUs)
let mut event_counts = HashMap::new();
for event in values {
assert!(key_map.contains_key(&event.to_string()));
let value = key_map.get(&event.to_string()).unwrap() + 1;
key_map.insert(event.to_string(), value);
if let Some(c) = event_counts.get_mut(&event) {
*c += 1;
} else {
event_counts.insert(event, 1);
}
}
let mut key_values: Vec<u64> = key_map.into_values().collect();
key_values.dedup();
assert_eq!(key_values.len(), 1);
let mut counts: Vec<_> = event_counts.into_values().collect();
counts.dedup();
assert_eq!(counts.len(), 1);
}
}
}
Expand Down
Loading