-
Notifications
You must be signed in to change notification settings - Fork 299
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge remote-tracking branch 'remotes/sbosnick/audit_header_name' int…
- Loading branch information
Showing
3 changed files
with
119 additions
and
18 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::{criterion_group, criterion_main, BenchmarkId,Criterion, Throughput}; | ||
use http::header::HeaderName; | ||
|
||
// This is a list of some of the standard headers ordered by increasing size. | ||
// It has exactly one standard header per size (some sizes don't have a standard | ||
// header). | ||
const STANDARD_HEADERS_BY_SIZE: &[&str] = &[ | ||
"te", | ||
"age", | ||
"date", | ||
"allow", | ||
"accept", | ||
"alt-svc", | ||
"if-match", | ||
"forwarded", | ||
"connection", | ||
"retry-after", | ||
"content-type", | ||
"accept-ranges", | ||
"accept-charset", | ||
"accept-encoding", | ||
"content-encoding", | ||
"if-modified-since", | ||
"proxy-authenticate", | ||
"content-disposition", | ||
"sec-websocket-accept", | ||
"sec-websocket-version", | ||
"access-control-max-age", | ||
"content-security-policy", | ||
"sec-websocket-extensions", | ||
"strict-transport-security", | ||
"access-control-allow-origin", | ||
"access-control-allow-headers", | ||
"access-control-expose-headers", | ||
"access-control-request-headers", | ||
"access-control-allow-credentials", | ||
"content-security-policy-report-only", | ||
]; | ||
|
||
fn header_name_by_size(c: &mut Criterion) { | ||
let mut group = c.benchmark_group("std_hdr"); | ||
for name in STANDARD_HEADERS_BY_SIZE { | ||
group.throughput(Throughput::Bytes(name.len() as u64)); | ||
group.bench_with_input(BenchmarkId::from_parameter(name), name, |b, name| { | ||
b.iter(|| HeaderName::from_static(name) ); | ||
}); | ||
} | ||
group.finish(); | ||
} | ||
|
||
criterion_group!(benches, header_name_by_size); | ||
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