use criterion::{black_box, criterion_group, criterion_main, BenchmarkId, Criterion}; use rattler_installs_packages::index::html::{parse_package_names_html, parse_project_info_html}; use std::str::FromStr; use url::Url; fn parse_project_info(c: &mut Criterion) { let html = r#" link1 link2 link3 "#; let url = Url::from_str("https://example.com/simple/link").unwrap(); c.bench_with_input( BenchmarkId::new("parse_project_info", "html"), &(html, url), |b, (html, url)| b.iter(|| parse_project_info_html(url, html)), ); } fn parse_package_names(c: &mut Criterion) { let html = r#" Simple index 0 0-._.-._.-._.-._.-._.-._.-0 000 0.0.1 00101s 00print_lol 00SMALINUX 0101 01changer 01d61084-d29e-11e9-96d1-7c5cf84ffe8e 01-distributions 021 024travis-test024 02exercicio 0411-test 0.618 0706xiaoye 0805nexter 090807040506030201testpip 0-core-client 0FELA 0html 0imap 0lever-so 0lever-utils 0-orchestrator 0proto 0rest 0rss 0wdg9nbmpm 0wneg 0x01-autocert-dns-aliyun 0x01-cubic-sdk 0x01-letsencrypt 0x0-python 0x10c-asm 0x20bf 0x2nac0nda 0x-contract-addresses 0x-contract-artifacts 0x-contract-wrappers "#; c.bench_function("parse_package_names", |b| { b.iter(|| parse_package_names_html(black_box(html))) }); } criterion_group!(benches, parse_project_info, parse_package_names); criterion_main!(benches);