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

add option to crox to filter out short events #60

Merged
merged 1 commit into from
Oct 1, 2019
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
7 changes: 6 additions & 1 deletion crox/src/main.rs
Original file line number Diff line number Diff line change
@@ -46,6 +46,9 @@ struct Opt {
/// collapse threads without overlapping events
#[structopt(long = "collapse-threads")]
collapse_threads: bool,
/// filter out events with shorter duration (in microseconds)
#[structopt(long = "minimum-duration")]
minimum_duration: u128,
}

// generate mapping from thread_id to collapsed thread_id or an empty map
@@ -130,7 +133,9 @@ fn main() -> Result<(), Box<dyn std::error::Error>> {
// only handle startStop events for now
if let MatchingEvent::StartStop(start, stop) = event {
let duration = stop.timestamp.duration_since(start.timestamp).unwrap();

if duration.as_micros() < opt.minimum_duration {
continue;
}
return Some(Event {
name: start.label.clone().into_owned(),
category: start.event_kind.clone().into_owned(),