Skip to content

Commit

Permalink
also use fuzz_add_sample
Browse files Browse the repository at this point in the history
  • Loading branch information
taegyunkim committed May 31, 2024
1 parent 7dd452d commit db18e70
Showing 1 changed file with 8 additions and 16 deletions.
24 changes: 8 additions & 16 deletions profiling/src/internal/profile/fuzz_tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -514,22 +514,14 @@ fn fuzz_add_sample_with_fixed_sample_length() {
.collect();

for (timestamp, sample) in samples.iter() {
profile
.add_sample(sample.into(), **timestamp)
.expect("Failed to add sample");
if timestamp.is_some() {
samples_with_timestamps.push(sample);
} else if let Some(existing_values) =
samples_without_timestamps.get_mut(&(&sample.locations, &sample.labels))
{
existing_values
.iter_mut()
.zip(sample.values.iter())
.for_each(|(a, b)| *a = a.saturating_add(*b));
} else {
samples_without_timestamps
.insert((&sample.locations, &sample.labels), sample.values.clone());
}
fuzz_add_sample(
timestamp,
sample,
sample_types,
&mut profile,
&mut samples_with_timestamps,
&mut samples_without_timestamps,
);
}
let serialized_profile =
pprof::roundtrip_to_pprof(profile).expect("Failed to roundtrip to pprof");
Expand Down

0 comments on commit db18e70

Please sign in to comment.