Skip to content

Commit adf92cf

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

1 file changed

Lines changed: 22 additions & 0 deletions

File tree

libdd-profiling/benches/add_samples.rs

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -111,6 +111,11 @@ pub fn bench_add_sample_vs_add2(c: &mut Criterion) {
111111
str: "",
112112
num: thread_id,
113113
num_unit: "",
114+
}, api::Label {
115+
key: "thread name",
116+
str: "this thread",
117+
num: 0,
118+
num_unit: "",
114119
}];
115120

116121
let frames2 = frames.map(|f| {
@@ -128,6 +133,23 @@ pub fn bench_add_sample_vs_add2(c: &mut Criterion) {
128133
});
129134
let dict = profiling::profiles::collections::Arc::try_new(dict).unwrap();
130135

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

0 commit comments

Comments
 (0)