fix Competition deserialisation
This commit is contained in:
parent
3b1da4d708
commit
6e1135e102
10 changed files with 405 additions and 155 deletions
|
|
@ -1,5 +1,5 @@
|
|||
use criterion::{criterion_group, criterion_main, Criterion};
|
||||
use torn_api::{faction, user, ThreadSafeApiClient};
|
||||
use torn_api::{faction, send::ApiClient, user};
|
||||
|
||||
pub fn user_benchmark(c: &mut Criterion) {
|
||||
dotenv::dotenv().unwrap();
|
||||
|
|
@ -54,12 +54,37 @@ pub fn faction_benchmark(c: &mut Criterion) {
|
|||
.unwrap()
|
||||
});
|
||||
|
||||
c.bench_function("user deserialize", |b| {
|
||||
c.bench_function("faction deserialize", |b| {
|
||||
b.iter(|| {
|
||||
response.basic().unwrap();
|
||||
})
|
||||
});
|
||||
}
|
||||
|
||||
criterion_group!(benches, user_benchmark, faction_benchmark);
|
||||
pub fn attacks_full(c: &mut Criterion) {
|
||||
dotenv::dotenv().unwrap();
|
||||
let rt = tokio::runtime::Builder::new_current_thread()
|
||||
.enable_io()
|
||||
.enable_time()
|
||||
.build()
|
||||
.unwrap();
|
||||
let response = rt.block_on(async {
|
||||
let key = std::env::var("APIKEY").expect("api key");
|
||||
let client = reqwest::Client::default();
|
||||
|
||||
client
|
||||
.torn_api(key)
|
||||
.faction(|b| b.selections(&[faction::Selection::AttacksFull]))
|
||||
.await
|
||||
.unwrap()
|
||||
});
|
||||
|
||||
c.bench_function("attacksfull deserialize", |b| {
|
||||
b.iter(|| {
|
||||
response.attacks_full().unwrap();
|
||||
})
|
||||
});
|
||||
}
|
||||
|
||||
criterion_group!(benches, user_benchmark, faction_benchmark, attacks_full);
|
||||
criterion_main!(benches);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue