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

Add benchmarks #2080

Merged
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
44 changes: 35 additions & 9 deletions opentelemetry/benches/attributes.rs
Original file line number Diff line number Diff line change
@@ -1,15 +1,17 @@
/* OS: Ubuntu 22.04.4 LTS (5.15.153.1-microsoft-standard-WSL2)
Hardware: Intel(R) Xeon(R) Platinum 8370C CPU @ 2.80GHz, 16vCPUs,
RAM: 64.0 GB
| Test | Average time|
|--------------------------------|-------------|
| CreateOTelKey_Static | 1.2 ns |
| CreateOTelKey_Owned | 12.6 ns |
| CreateOTelKey_Arc | 23.35 ns |
| CreateOTelKeyValue | 3.24 ns |
| CreateTupleKeyValue | 671 ps |
| CreateOtelKeyValueArray | 18.4 ns |
| CreateTupleKeyValueArray | 2.73 ns |
| Test | Average time|
|--------------------------------------------------|-------------|
| CreateOTelKey_Static | 1.2 ns |
| CreateOTelKey_Owned | 12.6 ns |
| CreateOTelKey_Arc | 23.35 ns |
| CreateOTelKeyValue | 3.24 ns |
| CreateTupleKeyValue | 671 ps |
| CreateOtelKeyValueArray | 18.4 ns |
| CreateOtelKeyValueArrayWithMixedValueTypes | 18.1 ns |
| CreateOtelKeyValueArrayWithNonStaticValues | 90.1 ns |
| CreateTupleKeyValueArray | 2.73 ns |
*/

use criterion::{black_box, criterion_group, criterion_main, Criterion};
Expand Down Expand Up @@ -65,6 +67,30 @@ fn attributes_creation(c: &mut Criterion) {
});
});

c.bench_function("CreateOtelKeyValueArrayWithMixedValueTypes", |b| {
b.iter(|| {
let _v1 = black_box([
KeyValue::new("attribute1", true),
KeyValue::new("attribute2", 100),
KeyValue::new("attribute3", 100.5),
KeyValue::new("attribute4", "value"),
]);
});
});

let value = "value1value2value3value4".to_owned();

c.bench_function("CreateOtelKeyValueArrayWithNonStaticValues", |b| {
b.iter(|| {
let _v1 = black_box([
KeyValue::new("attribute1", value[0..6].to_owned()), // value[0..6] = "value1"
KeyValue::new("attribute2", value[6..12].to_owned()), // value[6..12] = "value2"
KeyValue::new("attribute3", value[12..18].to_owned()), // value[12..18] = "value3"
KeyValue::new("attribute4", value[18..24].to_owned()), // value[18..24] = "value4"
]);
});
});

c.bench_function("CreateTupleKeyValueArray", |b| {
b.iter(|| {
let _v1 = black_box([
Expand Down
Loading