-
-
Notifications
You must be signed in to change notification settings - Fork 22
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
3 changed files
with
73 additions
and
67 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,41 +1,40 @@ | ||
use std::iter; | ||
|
||
use criterion::{black_box, criterion_group, criterion_main, Criterion}; | ||
use odbc_api::buffers::{try_buffer_from_description, buffer_from_description, BufferDescription}; | ||
|
||
fn falliable_buffer_allocation(capacity: usize, max_str_len: usize) { | ||
let description = BufferDescription { | ||
kind: odbc_api::buffers::BufferKind::Text { max_str_len }, | ||
nullable: true, | ||
}; | ||
try_buffer_from_description(capacity, iter::once(description)).unwrap(); | ||
} | ||
|
||
fn infalliable_buffer_allocation(capacity: usize, max_str_len: usize) { | ||
let description = BufferDescription { | ||
kind: odbc_api::buffers::BufferKind::Text { max_str_len }, | ||
nullable: true, | ||
}; | ||
buffer_from_description(capacity, iter::once(description)); | ||
} | ||
|
||
|
||
fn criterion_benchmark(c: &mut Criterion) { | ||
c.bench_function("fallibale buffer allocation", |b| { | ||
b.iter(|| { | ||
let capacity = 1000; | ||
let max_str_len = 65536; | ||
falliable_buffer_allocation(black_box(capacity), black_box(max_str_len)) | ||
}) | ||
}); | ||
c.bench_function("infallibale buffer allocation", |b| { | ||
b.iter(|| { | ||
let capacity = 1000; | ||
let max_str_len = 65536; | ||
infalliable_buffer_allocation(black_box(capacity), black_box(max_str_len)) | ||
}) | ||
}); | ||
} | ||
|
||
criterion_group!(benches, criterion_benchmark); | ||
criterion_main!(benches); | ||
use std::iter; | ||
|
||
use criterion::{black_box, criterion_group, criterion_main, Criterion}; | ||
use odbc_api::buffers::{buffer_from_description, try_buffer_from_description, BufferDescription}; | ||
|
||
fn falliable_buffer_allocation(capacity: usize, max_str_len: usize) { | ||
let description = BufferDescription { | ||
kind: odbc_api::buffers::BufferKind::Text { max_str_len }, | ||
nullable: true, | ||
}; | ||
try_buffer_from_description(capacity, iter::once(description)).unwrap(); | ||
} | ||
|
||
fn infalliable_buffer_allocation(capacity: usize, max_str_len: usize) { | ||
let description = BufferDescription { | ||
kind: odbc_api::buffers::BufferKind::Text { max_str_len }, | ||
nullable: true, | ||
}; | ||
buffer_from_description(capacity, iter::once(description)); | ||
} | ||
|
||
fn criterion_benchmark(c: &mut Criterion) { | ||
c.bench_function("fallibale buffer allocation", |b| { | ||
b.iter(|| { | ||
let capacity = 1000; | ||
let max_str_len = 65536; | ||
falliable_buffer_allocation(black_box(capacity), black_box(max_str_len)) | ||
}) | ||
}); | ||
c.bench_function("infallibale buffer allocation", |b| { | ||
b.iter(|| { | ||
let capacity = 1000; | ||
let max_str_len = 65536; | ||
infalliable_buffer_allocation(black_box(capacity), black_box(max_str_len)) | ||
}) | ||
}); | ||
} | ||
|
||
criterion_group!(benches, criterion_benchmark); | ||
criterion_main!(benches); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters