Skip to content

Commit

Permalink
Update doc and benchmarking code
Browse files Browse the repository at this point in the history
  • Loading branch information
yescallop committed Sep 15, 2024
1 parent 6180fcd commit 85dd65f
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 14 deletions.
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,8 @@ A generic URI/IRI handling library compliant with [RFC 3986] and [RFC 3987]. It
[RFC 3986]: https://datatracker.ietf.org/doc/html/rfc3986
[RFC 3987]: https://datatracker.ietf.org/doc/html/rfc3987
[^bench-res]: In [a benchmark](https://github.com/yescallop/fluent-uri-rs/blob/main/bench/benches/bench.rs)
on an Intel Core i5-11300H processor, `fluent-uri` parsed a URI
in 49ns compared to 89ns for `iref` and 135ns for `iri-string`.
on an Intel Core i5-11300H processor, `fluent-uri` parsed a 61-byte IRI
in ~85ns compared to ~125ns for `iref`, `iri-string` and `oxiri`.

## Terminology

Expand Down
19 changes: 8 additions & 11 deletions bench/benches/bench.rs
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
use criterion::{black_box, criterion_group, criterion_main, Criterion};
use fluent_uri::{component::Scheme, encoding::EStr, Uri, UriRef};
use fluent_uri::{component::Scheme, encoding::EStr, Iri, Uri, UriRef};
use iri_string::{
build::Builder,
format::ToDedicatedString,
types::{UriAbsoluteStr, UriReferenceStr, UriStr},
types::{IriStr, UriAbsoluteStr, UriReferenceStr, UriStr},
};
use url::Url;

Expand All @@ -29,24 +29,24 @@ const RESOLVE_CASE_BASE: &str = "http://example.com/foo/bar";
const RESOLVE_CASE_REF: &str = "../baz";

fn bench_parse(c: &mut Criterion) {
c.bench_function("parse", |b| b.iter(|| UriRef::parse(black_box(PARSE_CASE))));
c.bench_function("parse", |b| b.iter(|| Iri::parse(black_box(PARSE_CASE))));
}

fn bench_parse_iref(c: &mut Criterion) {
c.bench_function("parse_iref", |b| {
b.iter(|| iref::UriRef::new(black_box(PARSE_CASE)))
b.iter(|| iref::Iri::new(black_box(PARSE_CASE)))
});
}

fn bench_parse_iri_string(c: &mut Criterion) {
c.bench_function("parse_iri_string", |b| {
b.iter(|| UriReferenceStr::new(black_box(PARSE_CASE)))
b.iter(|| IriStr::new(black_box(PARSE_CASE)))
});
}

fn bench_parse_oxiri(c: &mut Criterion) {
c.bench_function("parse_oxiri", |b| {
b.iter(|| oxiri::IriRef::parse(black_box(PARSE_CASE)))
b.iter(|| oxiri::Iri::parse(black_box(PARSE_CASE)))
});
}

Expand All @@ -59,7 +59,7 @@ fn bench_parse_url(c: &mut Criterion) {
fn bench_build(c: &mut Criterion) {
c.bench_function("build", |b| {
b.iter(|| {
UriRef::builder()
Uri::builder()
.scheme(Scheme::new_or_panic("foo"))
.authority_with(|b| {
b.userinfo(EStr::new_or_panic("user"))
Expand All @@ -85,10 +85,7 @@ fn bench_build_iri_string(c: &mut Criterion) {
builder.path("/over/there");
builder.query("name=ferret");
builder.fragment("nose");
builder
.build::<UriReferenceStr>()
.unwrap()
.to_dedicated_string()
builder.build::<UriStr>().unwrap().to_dedicated_string()
})
});
}
Expand Down
1 change: 0 additions & 1 deletion src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,6 @@
//! [Reference resolution](UriRef::resolve_against). [Normalization](Uri::normalize).
//! [Percent-decoding](crate::encoding::EStr#examples).
//! [Percent-encoding](crate::encoding::EString#examples).
//! [Conversion from IRI to URI](Iri::to_uri).
//!
//! # Terminology
//!
Expand Down

0 comments on commit 85dd65f

Please sign in to comment.