-
-
Notifications
You must be signed in to change notification settings - Fork 1.6k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Co-authored-by: Rob Ede <robjtede@icloud.com>
- Loading branch information
Showing
5 changed files
with
152 additions
and
167 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
use criterion::{black_box, criterion_group, criterion_main, Criterion}; | ||
|
||
use std::borrow::Cow; | ||
|
||
fn compare_quoters(c: &mut Criterion) { | ||
let mut group = c.benchmark_group("Compare Quoters"); | ||
|
||
let quoter = actix_router::Quoter::new(b"", b""); | ||
let path_quoted = (0..=0x7f) | ||
.map(|c| format!("%{:02X}", c)) | ||
.collect::<String>(); | ||
let path_unquoted = ('\u{00}'..='\u{7f}').collect::<String>(); | ||
|
||
group.bench_function("quoter_unquoted", |b| { | ||
b.iter(|| { | ||
for _ in 0..10 { | ||
black_box(quoter.requote(path_unquoted.as_bytes())); | ||
} | ||
}); | ||
}); | ||
|
||
group.bench_function("percent_encode_unquoted", |b| { | ||
b.iter(|| { | ||
for _ in 0..10 { | ||
let decode = percent_encoding::percent_decode(path_unquoted.as_bytes()); | ||
black_box(Into::<Cow<'_, [u8]>>::into(decode)); | ||
} | ||
}); | ||
}); | ||
|
||
group.bench_function("quoter_quoted", |b| { | ||
b.iter(|| { | ||
for _ in 0..10 { | ||
black_box(quoter.requote(path_quoted.as_bytes())); | ||
} | ||
}); | ||
}); | ||
|
||
group.bench_function("percent_encode_quoted", |b| { | ||
b.iter(|| { | ||
for _ in 0..10 { | ||
let decode = percent_encoding::percent_decode(path_quoted.as_bytes()); | ||
black_box(Into::<Cow<'_, [u8]>>::into(decode)); | ||
} | ||
}); | ||
}); | ||
|
||
group.finish(); | ||
} | ||
|
||
criterion_group!(benches, compare_quoters); | ||
criterion_main!(benches); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.