Skip to content

Commit cde4875

Browse files
Add benchmark for timestamped add_sample
1 parent 3f3efef commit cde4875

File tree

1 file changed

+17
-0
lines changed

1 file changed

+17
-0
lines changed

libdd-profiling/benches/add_samples.rs

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -128,6 +128,23 @@ pub fn bench_add_sample_vs_add2(c: &mut Criterion) {
128128
});
129129
let dict = profiling::profiles::collections::Arc::try_new(dict).unwrap();
130130

131+
c.bench_function("profile_add_sample_timestamped_x1000", |b| {
132+
b.iter(|| {
133+
let mut profile = profiling::internal::Profile::try_new(&sample_types, None).unwrap();
134+
let (locations, values) = make_stack_api(frames.as_slice());
135+
for i in 0..1000 {
136+
let sample = api::Sample {
137+
locations: locations.clone(),
138+
values: &values,
139+
labels: labels_api.clone(),
140+
};
141+
let ts = std::num::NonZeroI64::new(i + 1);
142+
black_box(profile.try_add_sample(sample, ts)).unwrap();
143+
}
144+
black_box(profile.only_for_testing_num_aggregated_samples())
145+
})
146+
});
147+
131148
c.bench_function("profile_add_sample_frames_x1000", |b| {
132149
b.iter(|| {
133150
let mut profile = profiling::internal::Profile::try_new(&sample_types, None).unwrap();

0 commit comments

Comments
 (0)