Skip to content

Commit

Permalink
fix errors
Browse files Browse the repository at this point in the history
  • Loading branch information
nnyyxxxx committed Nov 27, 2024
1 parent 22f9cfc commit cca9d7a
Showing 1 changed file with 19 additions and 11 deletions.
30 changes: 19 additions & 11 deletions benches/nvrs_bench.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,36 +8,44 @@ fn configure_criterion() -> Criterion {
}

fn bench_config_load(c: &mut Criterion) {
use tokio::runtime::Runtime;
let rt = Runtime::new().unwrap();

c.bench_function("config_load", |b| {
b.iter(|| nvrs::config::load(black_box(None)))
b.iter(|| rt.block_on(nvrs::config::load(black_box(None))))
});
}

fn bench_verfile_operations(c: &mut Criterion) {
let (config_content, _, _) = nvrs::config::load(None);
use tokio::runtime::Runtime;
let rt = Runtime::new().unwrap();

let config = rt.block_on(nvrs::config::load(None)).unwrap();

c.bench_function("verfile_load", |b| {
b.iter(|| nvrs::verfiles::load(black_box(config_content.__config__.clone())))
b.iter(|| rt.block_on(nvrs::verfiles::load(black_box(config.0.__config__.clone()))))
});
}

fn bench_api_requests(c: &mut Criterion) {
use tokio::runtime::Runtime;
let rt = Runtime::new().unwrap();

let mock_package = nvrs::config::Package {
source: "aur".to_string(),
aur: "hyprland-git".to_string(),
github: String::new(),
gitlab: String::new(),
host: String::new(),
prefix: String::new(),
};
let mock_package = nvrs::config::Package::new(
"aur".to_string(),
"hyprland-git".to_string(),
false,
String::new(),
)
.unwrap();

let client = reqwest::Client::new();

c.bench_function("api_request", |b| {
b.iter(|| {
rt.block_on(nvrs::run_source(
("hyprland-git".to_string(), mock_package.clone()),
client.clone(),
None,
))
})
Expand Down

0 comments on commit cca9d7a

Please sign in to comment.