Skip to content

Commit edade8a

Browse files
committed
feat(hosted): wip dns checking
1 parent 83a7b73 commit edade8a

File tree

2 files changed

+89
-2
lines changed

2 files changed

+89
-2
lines changed

benches/match_rule_benchmark.rs

Lines changed: 88 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
#[macro_use]
22
extern crate criterion;
33
use criterion::{BenchmarkId, Criterion};
4+
use redirectionio::action::Action;
45
use redirectionio::api::{Rule, RulesMessage};
56
use redirectionio::http::Request;
67
use redirectionio::router::{Router, RouterConfig};
@@ -74,5 +75,91 @@ fn no_match_cache_bench(c: &mut Criterion) {
7475
group.finish();
7576
}
7677

77-
criterion_group!(benches, no_match_bench, no_match_cache_bench);
78+
fn match_rule_in_200k(c: &mut Criterion) {
79+
let config = RouterConfig::default();
80+
let mut router = create_router("../bench-files/large-rules-200k.json".to_string(), &config);
81+
let request = Request::from_config(
82+
&config,
83+
"/sites/default/files/image-gallery/lowtideonuseppaimage000000edited_0.jpg".to_string(),
84+
Some("usharbors.com".to_string()),
85+
None,
86+
None,
87+
None,
88+
None,
89+
);
90+
91+
router.cache(10000);
92+
93+
let mut group = c.benchmark_group("match_rule_in_200k");
94+
group.sample_size(10);
95+
96+
group.bench_function("match_rule_in_200k", |b| {
97+
b.iter(|| {
98+
router.match_request(&request);
99+
});
100+
});
101+
102+
group.finish();
103+
}
104+
105+
fn build_action_rule_in_200k(c: &mut Criterion) {
106+
let config = RouterConfig::default();
107+
let mut router = create_router("../bench-files/large-rules-200k.json".to_string(), &config);
108+
let request = Request::from_config(
109+
&config,
110+
"/sites/default/files/image-gallery/lowtideonuseppaimage000000edited_0.jpg".to_string(),
111+
Some("usharbors.com".to_string()),
112+
None,
113+
None,
114+
None,
115+
None,
116+
);
117+
118+
router.cache(1000);
119+
120+
let mut group = c.benchmark_group("build_action_rule_in_200k");
121+
group.sample_size(10);
122+
123+
group.bench_function("build_action_rule_in_200k", |b| {
124+
b.iter(|| {
125+
let rules = router.match_request(&request);
126+
let mut action = Action::from_routes_rule(rules.clone(), &request);
127+
128+
let action_status_code = action.get_status_code(0);
129+
let (_, backend_status_code) = if action_status_code != 0 {
130+
(action_status_code, action_status_code)
131+
} else {
132+
// We call the backend and get a response code
133+
let final_status_code = action.get_status_code(200);
134+
(final_status_code, 200)
135+
};
136+
137+
action.filter_headers(Vec::new(), backend_status_code, false);
138+
139+
let body = "<!DOCTYPE html>
140+
<html>
141+
<head>
142+
</head>
143+
<body>
144+
</body>
145+
</html>"
146+
.to_string();
147+
148+
if let Some(mut body_filter) = action.create_filter_body(backend_status_code) {
149+
body_filter.filter(body);
150+
body_filter.end();
151+
}
152+
});
153+
});
154+
155+
group.finish();
156+
}
157+
158+
criterion_group!(
159+
benches,
160+
no_match_bench,
161+
no_match_cache_bench,
162+
match_rule_in_200k,
163+
build_action_rule_in_200k
164+
);
78165
criterion_main!(benches);

src/router/config.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ impl Default for RouterConfig {
5252
ignore_marketing_query_params: true,
5353
marketing_query_params: parameters,
5454
pass_marketing_query_params_to_target: true,
55-
always_match_any_host: false,
55+
always_match_any_host: true,
5656
}
5757
}
5858
}

0 commit comments

Comments
 (0)