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 println!("1. Petit-Lancy, Les Esserts => Onex, Bandol");
39 plan_journey(
40 hrdf,
41 8587418,
42 8593027,
43 create_date_time(2025, 6, 1, 12, 30),
44 max_num_explorable_connections,
45 verbose,
46 );
47 println!("==============================================");
48
49 println!("2. Petit-Lancy, Les Esserts => Genève-Aéroport");
51 plan_journey(
52 hrdf,
53 8587418,
54 8501026,
55 create_date_time(2025, 2, 9, 14, 2),
56 max_num_explorable_connections,
57 verbose,
58 );
59 println!("==============================================");
60
61 println!("3. Avully, village => Pont-Céard, gare");
63 plan_journey(
64 hrdf,
65 8587031,
66 8593189,
67 create_date_time(2025, 7, 13, 16, 43),
68 max_num_explorable_connections,
69 verbose,
70 );
71 println!("==============================================");
72
73 println!("4. Petit-Lancy, Les Esserts => Vevey, Palud");
75 plan_journey(
76 hrdf,
77 8587418,
78 8595120,
79 create_date_time(2025, 9, 17, 5, 59),
80 max_num_explorable_connections,
81 verbose,
82 );
83 println!("==============================================");
84
85 println!("5. Genève, gare Cornavin => Avusy, village");
87 plan_journey(
88 hrdf,
89 8587057,
90 8587032,
91 create_date_time(2025, 10, 18, 20, 10),
92 max_num_explorable_connections,
93 verbose,
94 );
95 println!("==============================================");
96
97 println!("6. Genève => Bern, Bierhübeli");
99 plan_journey(
100 hrdf,
101 8501008,
102 8590028,
103 create_date_time(2025, 11, 22, 6, 59),
104 max_num_explorable_connections,
105 verbose,
106 );
107 println!("==============================================");
108
109 println!("7. Genève => Zürich HB");
111 plan_journey(
112 hrdf,
113 8501008,
114 8503000,
115 create_date_time(2025, 4, 9, 8, 4),
116 max_num_explorable_connections,
117 verbose,
118 );
119 println!("==============================================");
120
121 println!("8. Zürich HB => Lugano, Genzana");
123 plan_journey(
124 hrdf,
125 8503000,
126 8575310,
127 create_date_time(2025, 6, 15, 12, 10),
128 max_num_explorable_connections,
129 verbose,
130 );
131 println!("==============================================");
132
133 println!("9. Chancy, Douane => Campocologno");
135 plan_journey(
136 hrdf,
137 8587477,
138 8509368,
139 create_date_time(2025, 5, 29, 17, 29),
140 max_num_explorable_connections,
141 verbose,
142 );
143 println!("==============================================");
144
145 println!("10. Chancy, Douane => Sevelen, Post");
147 plan_journey(
148 hrdf,
149 8587477,
150 8581989,
151 create_date_time(2025, 9, 10, 13, 37),
152 max_num_explorable_connections,
153 true,
154 );
155 println!("==============================================");
156
157 println!("11. Genève => Paris gare de Lyon");
159 plan_journey(
160 hrdf,
161 8501008,
162 8768600,
163 create_date_time(2025, 4, 28, 8, 29),
164 max_num_explorable_connections,
165 true,
166 );
167 println!("==============================================");
168
169 println!("12. Genève => Lausanne");
171 plan_journey(
172 hrdf,
173 8501008,
174 8501120,
175 create_date_time(2025, 4, 28, 8, 20),
176 max_num_explorable_connections,
177 true,
178 );
179 println!("==============================================");
180
181 println!("\n{:.2?}", start_time.elapsed());
182}
183
184#[allow(dead_code)]
185pub fn test_find_reachable_stops_within_time_limit(hrdf: &Hrdf) {
186 let max_num_explorable_connections = 10;
187 let departure_stop_id = 8587418;
189 let departure_at = create_date_time(2025, 6, 1, 12, 30);
190
191 let start_time = Instant::now();
228 for time_limit in [60, 120, 180] {
229 let routes = find_reachable_stops_within_time_limit(
230 hrdf,
231 departure_stop_id,
232 departure_at,
233 Duration::minutes(time_limit),
234 max_num_explorable_connections,
235 false,
236 );
237
238 println!("\n{}", routes.len());
239 }
240
241 println!("{:.2?}", start_time.elapsed());
242}