Skip to content

Commit

Permalink
feat(test): add rudimentary bench
Browse files Browse the repository at this point in the history
Signed-off-by: Sandro-Alessio Gierens <[email protected]>
  • Loading branch information
gierens committed Feb 5, 2025
1 parent b928b3c commit 8e7bc8d
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 0 deletions.
4 changes: 4 additions & 0 deletions test/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,10 @@ path = "src/lib.rs"
name = "main"
path = "tests/main.rs"

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

[dependencies]
lrzcc = { version = "1.6", path = "../lib" }
lrzcc-api = { version = "0.6", path = "../api" }
Expand Down
24 changes: 24 additions & 0 deletions test/benches/main.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
#[macro_use]
extern crate bencher;

use bencher::Bencher;

use std::env;
use std::str::FromStr;

use lrzcc::{Api, Token};

fn bench_hello_user(b: &mut Bencher) {
let token =
Token::from_str(env::var("OS_TOKEN").unwrap().as_str()).unwrap();
let api =
Api::new("http://localhost:8000/api".to_string(), token, None, None)
.unwrap();

b.iter(|| {
api.hello.user().unwrap();
});
}

benchmark_group!(benches, bench_hello_user);
benchmark_main!(benches);

0 comments on commit 8e7bc8d

Please sign in to comment.