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’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix speedscope time interval #434

Merged
merged 2 commits into from
Aug 11, 2021
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 4 additions & 5 deletions src/speedscope.rs
Original file line number Diff line number Diff line change
Expand Up @@ -127,10 +127,6 @@ enum ValueUnit {

impl SpeedscopeFile {
pub fn new(samples: &HashMap<Tid, Vec<Vec<usize>>>, frames: &Vec<Frame>, thread_name_map: &HashMap<Tid, String>, sample_rate: u64) -> SpeedscopeFile {
let end_value = samples.len();

// we sample at 100 Hz, so scale the end value to match
let scaled_end_value = end_value as f64 / sample_rate as f64;
SpeedscopeFile {
// This is always the same
schema: "https://www.speedscope.app/file-format-schema.json".to_string(),
Expand All @@ -142,7 +138,10 @@ impl SpeedscopeFile {
exporter: Some(format!("py-spy@{}", env!("CARGO_PKG_VERSION"))),

profiles: samples.iter().map(|(thread_id, samples)| {
let weights: Vec<f64> = (&samples).iter().map(|_s| 1_f64).collect();
let end_value = samples.len();
// we sample at 100 Hz, so scale the end value and weights to match the time unit
let scaled_end_value = end_value as f64 / sample_rate as f64;
let weights: Vec<f64> = (&samples).iter().map(|_s| 1_f64 / sample_rate as f64).collect();

Profile {
profile_type: ProfileType::Sampled,
Expand Down