Skip to content

Commit

Permalink
More benchmarks
Browse files Browse the repository at this point in the history
  • Loading branch information
RReverser committed Sep 15, 2024
1 parent 3fa0f25 commit 9745906
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 5 deletions.
1 change: 1 addition & 0 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
"client",
"server",
"test",
"criterion",
],
"rust-analyzer.check.workspace": false
}
10 changes: 6 additions & 4 deletions src/client/benches/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ use criterion::Criterion;
use mime::APPLICATION_JSON;

macro_rules! declare_parsing_benches {
($($name:ident: $ty:ty => $fixture_path:literal,)*) => {
($($name:ident: $ty:ty => ($mime:expr, $fixture_path:literal),)*) => {
/// Run response parsing benchmarks against stored fixtures.
pub fn benches() {
let _ =
Expand All @@ -17,7 +17,7 @@ macro_rules! declare_parsing_benches {
.bench_function(stringify!($name), |b| {
b.iter(move || {
<$ty>::from_reqwest(
APPLICATION_JSON,
$mime,
Bytes::from_static(include_bytes!($fixture_path)),
)
.expect("Failed to parse fixture")
Expand All @@ -30,7 +30,9 @@ macro_rules! declare_parsing_benches {

declare_parsing_benches! {
parse_configured_devices: ValueResponse<Vec<ConfiguredDevice<FallibleDeviceType>>>
=> "resp_configured_devices.json",
=> (APPLICATION_JSON, "resp_configured_devices.json"),
parse_image_array: ASCOMResult<ImageArray>
=> "resp_image_array.json",
=> (APPLICATION_JSON, "resp_image_array.json"),
parse_image_array_bin: ASCOMResult<ImageArray>
=> ("application/imagebytes".parse().expect("couldn't parse mime type"), "resp_image_array.bin"),
}
Binary file added src/client/benches/resp_image_array.bin
Binary file not shown.
2 changes: 1 addition & 1 deletion src/client/benches/resp_image_array.json

Large diffs are not rendered by default.

0 comments on commit 9745906

Please sign in to comment.