Skip to content

Commit 389c484

Browse files
committed
add option to crox to filter out short events
add possibility to reduce the json file due to some files is to large to show in the browser. minimum_duration filter out all events that is shorter than specified duration
1 parent d9a055d commit 389c484

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)