Skip to content

Commit 77d2bab

Browse files
authored
Merge pull request #60 from andjo403/duration_filter
add option to crox to filter out short events
2 parents d9a055d + 389c484 commit 77d2bab

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

crox/src/main.rs

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,9 @@ struct Opt {
4646
/// collapse threads without overlapping events
4747
#[structopt(long = "collapse-threads")]
4848
collapse_threads: bool,
49+
/// filter out events with shorter duration (in microseconds)
50+
#[structopt(long = "minimum-duration")]
51+
minimum_duration: u128,
4952
}
5053

5154
// 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>> {
130133
// only handle startStop events for now
131134
if let MatchingEvent::StartStop(start, stop) = event {
132135
let duration = stop.timestamp.duration_since(start.timestamp).unwrap();
133-
136+
if duration.as_micros() < opt.minimum_duration {
137+
continue;
138+
}
134139
return Some(Event {
135140
name: start.label.clone().into_owned(),
136141
category: start.event_kind.clone().into_owned(),

0 commit comments

Comments
 (0)