-
-
Notifications
You must be signed in to change notification settings - Fork 361
Expand file tree
/
Copy pathheader_name2.rs
More file actions
53 lines (50 loc) · 1.53 KB
/
header_name2.rs
File metadata and controls
53 lines (50 loc) · 1.53 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
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",
"cross-origin-opener-policy",
"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);