1use std::time::Instant;
2
3use chrono::Duration;
4use hrdf_parser::Hrdf;
5
6use crate::{
7 routing::{find_reachable_stops_within_time_limit, plan_journey},
8 utils::create_date_time,
9};
10
11pub fn run_debug(hrdf: Hrdf) {
12 println!();
13 println!(
14 "------------------------------------------------------------------------------------------------"
15 );
16 println!("--- Debug");
17 println!(
18 "------------------------------------------------------------------------------------------------"
19 );
20
21 test_plan_journey(&hrdf);
22 test_find_reachable_stops_within_time_limit(&hrdf);
23}
24
25#[allow(dead_code)]
26pub fn test_plan_journey(hrdf: &Hrdf) {
27 let max_num_explorable_connections = 10;
32 let verbose = true;
33
34 println!();
35 let start_time = Instant::now();
36
37 plan_journey(
39 hrdf,
40 8587418,
41 8593027,
42 create_date_time(2025, 6, 1, 12, 30),
43 max_num_explorable_connections,
44 verbose,
45 );
46
47 plan_journey(
49 hrdf,
50 8587418,
51 8501026,
52 create_date_time(2025, 2, 9, 14, 2),
53 max_num_explorable_connections,
54 verbose,
55 );
56
57 plan_journey(
59 hrdf,
60 8587031,
61 8593189,
62 create_date_time(2025, 7, 13, 16, 43),
63 max_num_explorable_connections,
64 verbose,
65 );
66
67 plan_journey(
69 hrdf,
70 8587418,
71 8595120,
72 create_date_time(2025, 9, 17, 5, 59),
73 max_num_explorable_connections,
74 verbose,
75 );
76
77 plan_journey(
79 hrdf,
80 8587057,
81 8587032,
82 create_date_time(2025, 10, 18, 20, 10),
83 max_num_explorable_connections,
84 verbose,
85 );
86
87 plan_journey(
89 hrdf,
90 8501008,
91 8590028,
92 create_date_time(2025, 11, 22, 6, 59),
93 max_num_explorable_connections,
94 verbose,
95 );
96
97 plan_journey(
99 hrdf,
100 8501008,
101 8503000,
102 create_date_time(2025, 4, 9, 8, 4),
103 max_num_explorable_connections,
104 verbose,
105 );
106
107 plan_journey(
109 hrdf,
110 8503000,
111 8575310,
112 create_date_time(2025, 6, 15, 12, 10),
113 max_num_explorable_connections,
114 verbose,
115 );
116
117 plan_journey(
119 hrdf,
120 8587477,
121 8509368,
122 create_date_time(2025, 5, 29, 17, 29),
123 max_num_explorable_connections,
124 verbose,
125 );
126
127 plan_journey(
129 hrdf,
130 8587477,
131 8581989,
132 create_date_time(2025, 9, 10, 13, 37),
133 max_num_explorable_connections,
134 true,
135 );
136
137 plan_journey(
139 hrdf,
140 8501008,
141 8768600,
142 create_date_time(2025, 4, 28, 8, 29),
143 max_num_explorable_connections,
144 true,
145 );
146
147 plan_journey(
149 hrdf,
150 8501008,
151 8501120,
152 create_date_time(2025, 4, 28, 8, 20),
153 max_num_explorable_connections,
154 true,
155 );
156
157 println!("\n{:.2?}", start_time.elapsed());
158}
159
160#[allow(dead_code)]
161pub fn test_find_reachable_stops_within_time_limit(hrdf: &Hrdf) {
162 let max_num_explorable_connections = 10;
163 let departure_stop_id = 8587418;
165 let departure_at = create_date_time(2025, 6, 1, 12, 30);
166
167 let start_time = Instant::now();
204 for time_limit in [60, 120, 180] {
205 let routes = find_reachable_stops_within_time_limit(
206 hrdf,
207 departure_stop_id,
208 departure_at,
209 Duration::minutes(time_limit),
210 max_num_explorable_connections,
211 false,
212 );
213
214 println!("\n{}", routes.len());
215 }
216
217 println!("{:.2?}", start_time.elapsed());
218}
219#[cfg(test)]
220mod tests {
221 use crate::debug::{test_find_reachable_stops_within_time_limit, test_plan_journey};
222
223 use hrdf_parser::{Hrdf, Version};
224 use test_log::test;
225
226 #[test(tokio::test)]
227 async fn debug() {
228 let hrdf = Hrdf::new(
229 Version::V_5_40_41_2_0_7,
230 "https://data.opentransportdata.swiss/en/dataset/timetable-54-2025-hrdf/permalink",
231 false,
232 None,
233 )
234 .await
235 .unwrap();
236
237 test_plan_journey(&hrdf);
238 test_find_reachable_stops_within_time_limit(&hrdf);
239 }
240}