Skip to content

Commit 781c3ed

Browse files
committed
create vec of certain capacity
1 parent 17d1628 commit 781c3ed

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

opentelemetry-sdk/benches/growable_array.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ fn growable_array_insertion_benchmark(c: &mut Criterion) {
2828
fn vec_insertion_benchmark(c: &mut Criterion) {
2929
c.bench_function("Vec Insertion", |b| {
3030
b.iter(|| {
31-
let mut collection = Vec::new();
31+
let mut collection = Vec::with_capacity(10);
3232
for i in 0..8 {
3333
let key = Key::from(format!("key{}", i));
3434
let value = AnyValue::Int(i as i64);
@@ -72,7 +72,7 @@ fn growable_array_get_benchmark(c: &mut Criterion) {
7272

7373
fn vec_iteration_benchmark(c: &mut Criterion) {
7474
c.bench_function("Vec Iteration", |b| {
75-
let mut collection = Vec::new();
75+
let mut collection = Vec::with_capacity(10);
7676
for i in 0..8 {
7777
let key = Key::from(format!("key{}", i));
7878
let value = AnyValue::Int(i as i64);

0 commit comments

Comments
 (0)