/// Convert flame spans to the speedscope profile format.
Convert flame spans to the speedscope profile format.
Convert flame spans to the speedscope profile format .
pub fn spans_to_speedscope(spans: Vec<Span>) -> SpeedscopeFile {
    let mut frames = IndexSet::new();
    let profiles = spans
        .into_iter()
        .map(|span| Profile::Evented {
            name: span.name.clone(),
            unit: ValueUnit::Nanoseconds,
            start_value: span.start_ns,
            end_value: span.end_ns,
            events: {
                let mut events = Vec::new();
                span_extend_events(&mut frames, &mut events, span);
                events
            },
        })
        .collect();
    SpeedscopeFile {
        // always the same
        schema: JSON_SCHEMA_URL,
        active_profile_index: None,
        exporter: None,
        name: None,
        profiles,
        shared: Shared {
            frames: frames.into_iter().collect(),
        },
    }
}
pub fn spans_to_speedscope ( spans : Vec < Span > ) -> SpeedscopeFile { let mut frames = IndexSet :: new ( ) ; let profiles = spans . into_iter ( ) . map ( | span | Profile :: Evented { name : span . name . clone ( ) , unit : ValueUnit :: Nanoseconds , start_value : span . start_ns , end_value : span . end_ns , events : { let mut events = Vec :: new ( ) ; span_extend_events ( & mut frames , & mut events , span ) ; events } , } ) . collect ( ) ; SpeedscopeFile { // always the same schema : JSON_SCHEMA_URL , active_profile_index : None , exporter : None , name : None , profiles , shared : Shared { frames : frames . into_iter ( ) . collect ( ) , } , } }
Convert flame spans to the speedscope profile format.
Convert flame spans to the speedscope profile format .
spans
Vec<Span>