From bf22384c7d439320853efbda02b0baf4d691f387 Mon Sep 17 00:00:00 2001 From: Tae Gyun Kim Date: Wed, 29 May 2024 14:12:50 -0400 Subject: [PATCH] narrow search space by not using times --- profiling/src/internal/profile.rs | 19 ++++++------------- 1 file changed, 6 insertions(+), 13 deletions(-) diff --git a/profiling/src/internal/profile.rs b/profiling/src/internal/profile.rs index 8e08c89e2..b8f98a6e9 100644 --- a/profiling/src/internal/profile.rs +++ b/profiling/src/internal/profile.rs @@ -772,8 +772,8 @@ mod api_tests { let sample_length_gen = 1..=64usize; bolero::check!() - .with_generator((sample_length_gen, i64::gen(), u64::gen())) - .and_then(|(sample_len, start_time_ns, duration_ns)| { + .with_generator(sample_length_gen) + .and_then(|sample_len| { let sample_types = Vec::::gen().with().len(sample_len); let timestamps = Option::::gen(); @@ -790,16 +790,12 @@ mod api_tests { )>::gen() .with() .values((timestamps, locations, values, labels)); - (sample_types, samples, start_time_ns, duration_ns) + (sample_types, samples) }) - .for_each(|(sample_types, samples, start_time_ns, duration_ns)| { - let start_time = - SystemTime::from(chrono::DateTime::from_timestamp_nanos(*start_time_ns)); - let duration = Duration::from_nanos(*duration_ns); - let end_time = start_time + duration; + .for_each(|(sample_types, samples)| { let api_sample_types: Vec<_> = sample_types.iter().map(api::ValueType::from).collect(); - let mut profile = Profile::new(start_time, &api_sample_types, None); + let mut profile = Profile::new(SystemTime::now(), &api_sample_types, None); let mut samples_with_timestamps = Vec::new(); let mut samples_without_timestamps: HashMap< (&Vec, &Vec), @@ -841,11 +837,8 @@ mod api_tests { .insert((&sample.locations, &sample.labels), sample.values.clone()); } } - let encoded = profile - .serialize_into_compressed_pprof(Some(end_time), Some(duration)) - .unwrap(); let serialized_profile = - pprof::deserialize_compressed_pprof(&encoded.buffer).unwrap(); + pprof::roundtrip_to_pprof(profile).expect("Failed to roundtrip to pprof"); assert_sample_types_eq(&serialized_profile, sample_types); assert_samples_eq(