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鈥檒l occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add current sample rate to print summary #191

Merged
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
6 changes: 3 additions & 3 deletions src/main.rs
Expand Up @@ -437,7 +437,7 @@ fn parallel_record(

// Print a summary every second
if std::time::Instant::now() > summary_time {
print_summary(&summary_out, &start_time, timing_error_traces.load(Ordering::Relaxed), total_traces.load(Ordering::Relaxed))?;
print_summary(&summary_out, &start_time, sample_rate, timing_error_traces.load(Ordering::Relaxed), total_traces.load(Ordering::Relaxed))?;
summary_time = std::time::Instant::now() + Duration::from_secs(1);
}
}
Expand Down Expand Up @@ -550,7 +550,7 @@ fn report(format: OutputFormat, input: PathBuf, output: PathBuf) -> Result<(), E
Ok(())
}

fn print_summary(summary_out: &ui::summary::Stats, start_time: &Instant, timing_error_traces: usize, total_traces: usize) -> Result<(), Error> {
fn print_summary(summary_out: &ui::summary::Stats, start_time: &Instant, sample_rate: u32, timing_error_traces: usize, total_traces: usize) -> Result<(), Error> {
let width = match term_size::dimensions() {
Some((w, _)) => Some(w as usize),
None => None,
Expand All @@ -565,7 +565,7 @@ fn print_summary(summary_out: &ui::summary::Stats, start_time: &Instant, timing_
if total_traces > 100 && percent_timing_error > 0.5 {
// Only print if timing errors are more than 0.5% of total traces -- it's a statistical
// profiler so smaller differences don't really matter
eprintln!("{:.1}% ({}/{}) of stack traces were sampled late because we couldn't sample at expected rate, results may be inaccurate. Try sampling at a lower rate with `--rate`.", percent_timing_error, timing_error_traces, total_traces);
eprintln!("{:.1}% ({}/{}) of stack traces were sampled late because we couldn't sample at expected rate, results may be inaccurate. Current rate: {}. Try sampling at a lower rate with `--rate`.", percent_timing_error, timing_error_traces, total_traces, sample_rate);
}
Ok(())
}
Expand Down