async fn export_hdr_log(conf: HdrCommand) -> Result<()> {
    let tag_prefix = conf.tag.map(|t| t + ".").unwrap_or_else(|| "".to_string());
    if tag_prefix.chars().any(|c| ", \n\t".contains(c)) {
        eprintln!("error: Hdr histogram tags are not allowed to contain commas nor whitespace.");
        exit(255);
    }

    let report = load_report_or_abort(&conf.report);
    let stdout = stdout();
    let output_file: File;
    let stdout_stream;
    let mut out: Box<dyn Write> = match conf.output {
        Some(path) => {
            output_file = File::create(&path).map_err(|e| LatteError::OutputFileCreate(path, e))?;
            Box::new(output_file)
        }
        None => {
            stdout_stream = stdout.lock();
            Box::new(stdout_stream)
        }
    };

    let mut serializer = V2DeflateSerializer::new();
    let mut log_writer = interval_log::IntervalLogWriterBuilder::new()
        .add_comment(format!("[Logged with Latte {}]", VERSION).as_str())
        .with_start_time(report.result.start_time.into())
        .with_base_time(report.result.start_time.into())
        .with_max_value_divisor(1000000.0) // ms
        .begin_log_with(&mut out, &mut serializer)
        .unwrap();

    for sample in &report.result.log {
        let interval_start_time = Duration::from_millis((sample.time_s * 1000.0) as u64);
        let interval_duration = Duration::from_millis((sample.duration_s * 1000.0) as u64);
        log_writer.write_histogram(
            &sample.cycle_time_histogram_ns.0,
            interval_start_time,
            interval_duration,
            Tag::new(format!("{}cycles", tag_prefix).as_str()),
        )?;
        log_writer.write_histogram(
            &sample.resp_time_histogram_ns.0,
            interval_start_time,
            interval_duration,
            Tag::new(format!("{}requests", tag_prefix).as_str()),
        )?;
    }
    Ok(())
}
/// Reads histograms from the report and dumps them to an hdr log
Reads histograms from the report and dumps them to an hdr log
Reads histograms from the report and dumps them to an hdr log
async fn export_hdr_log(conf: HdrCommand) -> Result<()> {
    let tag_prefix = conf.tag.map(|t| t + ".").unwrap_or_else(|| "".to_string());
    if tag_prefix.chars().any(|c| ", \n\t".contains(c)) {
        eprintln!("error: Hdr histogram tags are not allowed to contain commas nor whitespace.");
        exit(255);
    }
    let report = load_report_or_abort(&conf.report);
    let stdout = stdout();
    let output_file: File;
    let stdout_stream;
    let mut out: Box<dyn Write> = match conf.output {
        Some(path) => {
            output_file = File::create(&path).map_err(|e| LatteError::OutputFileCreate(path, e))?;
            Box::new(output_file)
        }
        None => {
            stdout_stream = stdout.lock();
            Box::new(stdout_stream)
        }
    };
    let mut serializer = V2DeflateSerializer::new();
    let mut log_writer = interval_log::IntervalLogWriterBuilder::new()
        .add_comment(format!("[Logged with Latte {}]", VERSION).as_str())
        .with_start_time(report.result.start_time.into())
        .with_base_time(report.result.start_time.into())
        .with_max_value_divisor(1000000.0) // ms
        .begin_log_with(&mut out, &mut serializer)
        .unwrap();
    for sample in &report.result.log {
        let interval_start_time = Duration::from_millis((sample.time_s * 1000.0) as u64);
        let interval_duration = Duration::from_millis((sample.duration_s * 1000.0) as u64);
        log_writer.write_histogram(
            &sample.cycle_time_histogram_ns.0,
            interval_start_time,
            interval_duration,
            Tag::new(format!("{}cycles", tag_prefix).as_str()),
        )?;
        log_writer.write_histogram(
            &sample.resp_time_histogram_ns.0,
            interval_start_time,
            interval_duration,
            Tag::new(format!("{}requests", tag_prefix).as_str()),
        )?;
    }
    Ok(())
}
async fn export_hdr_log ( conf : HdrCommand ) -> Result < ( ) > { let tag_prefix = conf . tag . map ( | t | t + " " ) . unwrap_or_else ( | | " " . to_string ( ) ) ; if tag_prefix . chars ( ) . any ( | c | " \n \t " . contains ( c ) ) { eprintln ! ( " " ) ; exit ( 255 ) ; } let report = load_report_or_abort ( & conf . report ) ; let stdout = stdout ( ) ; let output_file : File ; let stdout_stream ; let mut out : Box < dyn Write > = match conf . output { Some ( path ) => { output_file = File :: create ( & path ) . map_err ( | e | LatteError :: OutputFileCreate ( path , e ) ) ? ; Box :: new ( output_file ) } None => { stdout_stream = stdout . lock ( ) ; Box :: new ( stdout_stream ) } } ; let mut serializer = V2DeflateSerializer :: new ( ) ; let mut log_writer = interval_log :: IntervalLogWriterBuilder :: new ( ) . add_comment ( format ! ( " " VERSION ) . as_str ( ) ) . with_start_time ( report . result . start_time . into ( ) ) . with_base_time ( report . result . start_time . into ( ) ) . with_max_value_divisor ( 1000000.0 ) // ms . begin_log_with ( & mut out , & mut serializer ) . unwrap ( ) ; for sample in & report . result . log { let interval_start_time = Duration :: from_millis ( ( sample . time_s * 1000.0 ) as u64 ) ; let interval_duration = Duration :: from_millis ( ( sample . duration_s * 1000.0 ) as u64 ) ; log_writer . write_histogram ( & sample . cycle_time_histogram_ns . 0 , interval_start_time , interval_duration , Tag :: new ( format ! ( " " tag_prefix ) . as_str ( ) ) , ) ? ; log_writer . write_histogram ( & sample . resp_time_histogram_ns . 0 , interval_start_time , interval_duration , Tag :: new ( format ! ( " " tag_prefix ) . as_str ( ) ) , ) ? ; } Ok ( ( ) ) }
Reads histograms from the report and dumps them to an hdr log
Reads histograms from the report and dumps them to an hdr log
conf
HdrCommand
conf
HdrCommand