Skip to content

Commit

Permalink
add basic auth bench
Browse files Browse the repository at this point in the history
  • Loading branch information
aumetra committed Dec 17, 2024
1 parent 980de63 commit f8ea1a6
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 0 deletions.
4 changes: 4 additions & 0 deletions lib/komainu/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,10 @@ edition.workspace = true
version.workspace = true
license = "MIT OR Apache-2.0"

[[bench]]
name = "basic_auth"
harness = false

[[bench]]
name = "pkce"
harness = false
Expand Down
21 changes: 21 additions & 0 deletions lib/komainu/benches/basic_auth.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
use divan::{black_box, black_box_drop};
use komainu::extractor::BasicAuth;

#[divan::bench]
fn rfc_value(b: divan::Bencher<'_, '_>) {
let mut map = http::HeaderMap::new();
map.insert(
http::header::AUTHORIZATION,
http::HeaderValue::from_static("Basic QWxhZGRpbjpvcGVuIHNlc2FtZQ=="),
);

b.bench(|| {
let auth = BasicAuth::extract(black_box(&map)).unwrap();
black_box_drop((auth.username(), auth.password()));
auth
});
}

fn main() {
divan::main();
}

0 comments on commit f8ea1a6

Please sign in to comment.