Skip to content

Commit ae58257

Browse files
committed
perf: update benchmarks
1 parent 1f28d25 commit ae58257

File tree

2 files changed

+29
-42
lines changed

2 files changed

+29
-42
lines changed

README.md

Lines changed: 6 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -28,21 +28,14 @@ fn main() {
2828

2929
### Performance
3030

31-
Ada is fast. The benchmark below shows **2 times** faster URL parsing compared to `url`
31+
Ada is fast. The benchmark below shows **3.34 times** faster URL parsing compared to `url`
3232

3333
```
34-
Running bench/parse.rs (target/release/deps/parse-dff65469468a2cec)
35-
url_parse/ada_parse time: [2.5853 µs 2.5982 µs 2.6115 µs]
36-
change: [-3.8745% -2.9874% -2.0620%] (p = 0.00 < 0.05)
37-
Performance has improved.
38-
Found 2 outliers among 100 measurements (2.00%)
39-
1 (1.00%) low mild
40-
1 (1.00%) high severe
41-
url_parse/servo_parse time: [5.5127 µs 5.6287 µs 5.8046 µs]
42-
change: [+0.7618% +3.0977% +6.5694%] (p = 0.01 < 0.05)
43-
Change within noise threshold.
44-
Found 2 outliers among 100 measurements (2.00%)
45-
2 (2.00%) high severe
34+
parse/ada_url time: [2.0790 µs 2.0812 µs 2.0835 µs]
35+
thrpt: [369.84 MiB/s 370.25 MiB/s 370.65 MiB/s]
36+
37+
parse/url time: [6.9266 µs 6.9677 µs 7.0199 µs]
38+
thrpt: [109.77 MiB/s 110.59 MiB/s 111.25 MiB/s]
4639
```
4740

4841
### Implemented traits

bench/parse.rs

Lines changed: 23 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -1,44 +1,38 @@
1-
use ada_url::Url;
2-
use criterion::{black_box, criterion_group, criterion_main, Criterion};
1+
use criterion::{black_box, criterion_group, criterion_main, Criterion, Throughput};
32

4-
const URL: &[&str] = &[
5-
"https://www.google.com/",
6-
"webhp?hl=en&amp;ictx=2&amp;sa=X&amp;ved=0ahUKEwil_",
7-
"oSxzJj8AhVtEFkFHTHnCGQQPQgI",
8-
"https://support.google.com/websearch/",
9-
"?p=ws_results_help&amp;hl=en-CA&amp;fg=1",
3+
const URLS: &[&str] = &[
4+
"https://www.google.com/webhp?hl=en&amp;ictx=2&amp;sa=X&amp;ved=0ahUKEwil_oSxzJj8AhVtEFkFHTHnCGQQPQgI",
5+
"https://support.google.com/websearch/?p=ws_results_help&amp;hl=en-CA&amp;fg=1",
106
"https://en.wikipedia.org/wiki/Dog#Roles_with_humans",
117
"https://www.tiktok.com/@aguyandagolden/video/7133277734310038830",
12-
"https://business.twitter.com/en/help/troubleshooting/",
13-
"how-twitter-ads-work.html?ref=web-twc-ao-gbl-adsinfo&utm_source=twc&utm_",
14-
"medium=web&utm_campaign=ao&utm_content=adsinfo",
15-
"https://images-na.ssl-images-amazon.com/images/I/",
16-
"41Gc3C8UysL.css?AUIClients/AmazonGatewayAuiAssets",
8+
"https://business.twitter.com/en/help/troubleshooting/how-twitter-ads-work.html?ref=web-twc-ao-gbl-adsinfo&utm_source=twc&utm_medium=web&utm_campaign=ao&utm_content=adsinfo",
9+
"https://images-na.ssl-images-amazon.com/images/I/41Gc3C8UysL.css?AUIClients/AmazonGatewayAuiAssets",
1710
"https://www.reddit.com/?after=t3_zvz1ze",
1811
"https://www.reddit.com/login/?dest=https%3A%2F%2Fwww.reddit.com%2F",
19-
"postgresql://other:9818274x1!!@localhost:5432/",
20-
"otherdb?connect_timeout=10&application_name=myapp",
12+
"postgresql://other:9818274x1!!@localhost:5432/otherdb?connect_timeout=10&application_name=myapp",
2113
"http://192.168.1.1", // ipv4
2214
"http://[2606:4700:4700::1111]", // ipv6
2315
];
2416

25-
fn bench_url_parse(b: &mut Criterion) {
26-
b.benchmark_group("url_parse")
27-
.bench_function("ada_parse", |b| {
28-
b.iter(|| {
29-
URL.iter().for_each(|url| {
30-
let _ = Url::parse(black_box(url), None);
31-
});
17+
pub fn parse_benchmark(c: &mut Criterion) {
18+
let mut group = c.benchmark_group("parse");
19+
group.throughput(Throughput::Bytes(URLS.iter().map(|u| u.len() as u64).sum()));
20+
group.bench_function("ada_url", |b| {
21+
b.iter(|| {
22+
URLS.iter().for_each(|url| {
23+
black_box(url).parse::<ada_url::Url>().unwrap();
3224
})
3325
})
34-
.bench_function("servo_parse", |b| {
35-
b.iter(|| {
36-
URL.iter().for_each(|url| {
37-
let _ = url::Url::parse(black_box(url));
38-
});
26+
});
27+
group.bench_function("url", |b| {
28+
b.iter(|| {
29+
URLS.iter().for_each(|url| {
30+
black_box(url).parse::<url::Url>().unwrap();
3931
})
40-
});
32+
})
33+
});
34+
group.finish();
4135
}
4236

43-
criterion_group!(benches, bench_url_parse);
37+
criterion_group!(benches, parse_benchmark);
4438
criterion_main!(benches);

0 commit comments

Comments
 (0)