fix Competition deserialisation

This commit is contained in:
TotallyNot 2023-01-22 00:50:16 +01:00
parent 768c63b731
commit 3d756656f1
10 changed files with 405 additions and 155 deletions

View file

@ -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);