Skip to content

Commit

Permalink
Add benchmark
Browse files Browse the repository at this point in the history
  • Loading branch information
Markus Westerlind committed Jun 20, 2018
1 parent 04d5ec1 commit c493261
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 0 deletions.
6 changes: 6 additions & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,8 @@ rustc-test = "0.3"
rustc-serialize = "0.3"
serde_json = ">=0.6.1, <0.9"

bencher = "0.1"

[features]
query_encoding = ["encoding"]
heap_size = ["heapsize"]
Expand All @@ -48,5 +50,9 @@ percent-encoding = { version = "1.0.0", path = "./percent_encoding" }
rustc-serialize = {version = "0.3", optional = true}
serde = {version = ">=0.6.1, <0.9", optional = true}

[[bench]]
name = "parse_url"
harness = false

[package.metadata.docs.rs]
features = ["query_encoding"]
18 changes: 18 additions & 0 deletions benches/parse_url.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
#[macro_use]
extern crate bencher;

extern crate url;

use bencher::{black_box, Bencher};

use url::Url;

fn short(bench: &mut Bencher) {
let url = "https://example.com/bench";

bench.bytes = url.len() as u64;
bench.iter(|| black_box(url).parse::<Url>().unwrap());
}

benchmark_group!(benches, short);
benchmark_main!(benches);

0 comments on commit c493261

Please sign in to comment.