|
3 | 3 | extern crate test; |
4 | 4 |
|
5 | 5 | macro_rules! benchmark { |
6 | | - ($year:tt, $day:tt) => { |
7 | | - mod $day { |
8 | | - use aoc::$year::$day::*; |
9 | | - use std::fs::read_to_string; |
10 | | - use std::path::Path; |
11 | | - use std::sync::LazyLock; |
12 | | - use test::Bencher; |
| 6 | + ($year:tt $($day:tt),*) => { |
| 7 | + mod $year {$( |
| 8 | + mod $day { |
| 9 | + use aoc::$year::$day::*; |
| 10 | + use std::fs::read_to_string; |
| 11 | + use std::path::Path; |
| 12 | + use std::sync::LazyLock; |
| 13 | + use test::Bencher; |
13 | 14 |
|
14 | | - static DATA: LazyLock<String> = LazyLock::new(|| { |
15 | | - let year = stringify!($year); |
16 | | - let day = stringify!($day); |
17 | | - let path = Path::new("input").join(year).join(day).with_extension("txt"); |
18 | | - read_to_string(path).unwrap() |
19 | | - }); |
| 15 | + static DATA: LazyLock<String> = LazyLock::new(|| { |
| 16 | + let year = stringify!($year); |
| 17 | + let day = stringify!($day); |
| 18 | + let path = Path::new("input").join(year).join(day).with_extension("txt"); |
| 19 | + read_to_string(path).unwrap() |
| 20 | + }); |
20 | 21 |
|
21 | | - #[bench] |
22 | | - fn parse_bench(b: &mut Bencher) { |
23 | | - let data = &DATA; |
24 | | - b.iter(|| parse(data)); |
25 | | - } |
| 22 | + #[bench] |
| 23 | + fn parse_bench(b: &mut Bencher) { |
| 24 | + let data = &DATA; |
| 25 | + b.iter(|| parse(data)); |
| 26 | + } |
26 | 27 |
|
27 | | - #[bench] |
28 | | - fn part1_bench(b: &mut Bencher) { |
29 | | - let input = parse(&DATA); |
30 | | - b.iter(|| part1(&input)); |
31 | | - } |
| 28 | + #[bench] |
| 29 | + fn part1_bench(b: &mut Bencher) { |
| 30 | + let input = parse(&DATA); |
| 31 | + b.iter(|| part1(&input)); |
| 32 | + } |
32 | 33 |
|
33 | | - #[bench] |
34 | | - fn part2_bench(b: &mut Bencher) { |
35 | | - let input = parse(&DATA); |
36 | | - b.iter(|| part2(&input)); |
| 34 | + #[bench] |
| 35 | + fn part2_bench(b: &mut Bencher) { |
| 36 | + let input = parse(&DATA); |
| 37 | + b.iter(|| part2(&input)); |
| 38 | + } |
37 | 39 | } |
38 | | - } |
39 | | - }; |
| 40 | + )*} |
| 41 | + } |
40 | 42 | } |
41 | 43 |
|
42 | | -mod year2015 { |
43 | | - benchmark!(year2015, day01); |
44 | | - benchmark!(year2015, day02); |
45 | | - benchmark!(year2015, day03); |
46 | | - benchmark!(year2015, day04); |
47 | | - benchmark!(year2015, day05); |
48 | | - benchmark!(year2015, day06); |
49 | | - benchmark!(year2015, day07); |
50 | | - benchmark!(year2015, day08); |
51 | | - benchmark!(year2015, day09); |
52 | | - benchmark!(year2015, day10); |
53 | | - benchmark!(year2015, day11); |
54 | | - benchmark!(year2015, day12); |
55 | | - benchmark!(year2015, day13); |
56 | | - benchmark!(year2015, day14); |
57 | | - benchmark!(year2015, day15); |
58 | | - benchmark!(year2015, day16); |
59 | | - benchmark!(year2015, day17); |
60 | | - benchmark!(year2015, day18); |
61 | | - benchmark!(year2015, day19); |
62 | | - benchmark!(year2015, day20); |
63 | | - benchmark!(year2015, day21); |
64 | | - benchmark!(year2015, day22); |
65 | | - benchmark!(year2015, day23); |
66 | | - benchmark!(year2015, day24); |
67 | | - benchmark!(year2015, day25); |
68 | | -} |
| 44 | +benchmark!(year2015 |
| 45 | + day01, day02, day03, day04, day05, day06, day07, day08, day09, day10, day11, day12, day13, |
| 46 | + day14, day15, day16, day17, day18, day19, day20, day21, day22, day23, day24, day25 |
| 47 | +); |
69 | 48 |
|
70 | | -mod year2016 { |
71 | | - benchmark!(year2016, day01); |
72 | | - benchmark!(year2016, day02); |
73 | | - benchmark!(year2016, day03); |
74 | | - benchmark!(year2016, day04); |
75 | | - benchmark!(year2016, day05); |
76 | | - benchmark!(year2016, day06); |
77 | | - benchmark!(year2016, day07); |
78 | | - benchmark!(year2016, day08); |
79 | | - benchmark!(year2016, day09); |
80 | | - benchmark!(year2016, day10); |
81 | | - benchmark!(year2016, day11); |
82 | | - benchmark!(year2016, day12); |
83 | | - benchmark!(year2016, day13); |
84 | | - benchmark!(year2016, day14); |
85 | | - benchmark!(year2016, day15); |
86 | | - benchmark!(year2016, day16); |
87 | | - benchmark!(year2016, day17); |
88 | | - benchmark!(year2016, day18); |
89 | | - benchmark!(year2016, day19); |
90 | | - benchmark!(year2016, day20); |
91 | | - benchmark!(year2016, day21); |
92 | | - benchmark!(year2016, day22); |
93 | | - benchmark!(year2016, day23); |
94 | | - benchmark!(year2016, day24); |
95 | | - benchmark!(year2016, day25); |
96 | | -} |
| 49 | +benchmark!(year2016 |
| 50 | + day01, day02, day03, day04, day05, day06, day07, day08, day09, day10, day11, day12, day13, |
| 51 | + day14, day15, day16, day17, day18, day19, day20, day21, day22, day23, day24, day25 |
| 52 | +); |
97 | 53 |
|
98 | | -mod year2017 { |
99 | | - benchmark!(year2017, day01); |
100 | | - benchmark!(year2017, day02); |
101 | | - benchmark!(year2017, day03); |
102 | | - benchmark!(year2017, day04); |
103 | | - benchmark!(year2017, day05); |
104 | | - benchmark!(year2017, day06); |
105 | | - benchmark!(year2017, day07); |
106 | | - benchmark!(year2017, day08); |
107 | | - benchmark!(year2017, day09); |
108 | | - benchmark!(year2017, day10); |
109 | | - benchmark!(year2017, day11); |
110 | | - benchmark!(year2017, day12); |
111 | | - benchmark!(year2017, day13); |
112 | | - benchmark!(year2017, day14); |
113 | | - benchmark!(year2017, day15); |
114 | | - benchmark!(year2017, day16); |
115 | | - benchmark!(year2017, day17); |
116 | | - benchmark!(year2017, day18); |
117 | | - benchmark!(year2017, day19); |
118 | | - benchmark!(year2017, day20); |
119 | | - benchmark!(year2017, day21); |
120 | | - benchmark!(year2017, day22); |
121 | | - benchmark!(year2017, day23); |
122 | | - benchmark!(year2017, day24); |
123 | | - benchmark!(year2017, day25); |
124 | | -} |
| 54 | +benchmark!(year2017 |
| 55 | + day01, day02, day03, day04, day05, day06, day07, day08, day09, day10, day11, day12, day13, |
| 56 | + day14, day15, day16, day17, day18, day19, day20, day21, day22, day23, day24, day25 |
| 57 | +); |
125 | 58 |
|
126 | | -mod year2018 { |
127 | | - benchmark!(year2018, day01); |
128 | | - benchmark!(year2018, day02); |
129 | | - benchmark!(year2018, day03); |
130 | | - benchmark!(year2018, day04); |
131 | | - benchmark!(year2018, day05); |
132 | | - benchmark!(year2018, day06); |
133 | | - benchmark!(year2018, day07); |
134 | | - benchmark!(year2018, day08); |
135 | | - benchmark!(year2018, day09); |
136 | | - benchmark!(year2018, day10); |
137 | | - benchmark!(year2018, day11); |
138 | | - benchmark!(year2018, day12); |
139 | | - benchmark!(year2018, day13); |
140 | | - benchmark!(year2018, day14); |
141 | | - benchmark!(year2018, day15); |
142 | | - benchmark!(year2018, day16); |
143 | | - benchmark!(year2018, day17); |
144 | | - benchmark!(year2018, day18); |
145 | | - benchmark!(year2018, day19); |
146 | | - benchmark!(year2018, day20); |
147 | | - benchmark!(year2018, day21); |
148 | | - benchmark!(year2018, day22); |
149 | | - benchmark!(year2018, day23); |
150 | | - benchmark!(year2018, day24); |
151 | | - benchmark!(year2018, day25); |
152 | | -} |
| 59 | +benchmark!(year2018 |
| 60 | + day01, day02, day03, day04, day05, day06, day07, day08, day09, day10, day11, day12, day13, |
| 61 | + day14, day15, day16, day17, day18, day19, day20, day21, day22, day23, day24, day25 |
| 62 | +); |
153 | 63 |
|
154 | | -mod year2019 { |
155 | | - benchmark!(year2019, day01); |
156 | | - benchmark!(year2019, day02); |
157 | | - benchmark!(year2019, day03); |
158 | | - benchmark!(year2019, day04); |
159 | | - benchmark!(year2019, day05); |
160 | | - benchmark!(year2019, day06); |
161 | | - benchmark!(year2019, day07); |
162 | | - benchmark!(year2019, day08); |
163 | | - benchmark!(year2019, day09); |
164 | | - benchmark!(year2019, day10); |
165 | | - benchmark!(year2019, day11); |
166 | | - benchmark!(year2019, day12); |
167 | | - benchmark!(year2019, day13); |
168 | | - benchmark!(year2019, day14); |
169 | | - benchmark!(year2019, day15); |
170 | | - benchmark!(year2019, day16); |
171 | | - benchmark!(year2019, day17); |
172 | | - benchmark!(year2019, day18); |
173 | | - benchmark!(year2019, day19); |
174 | | - benchmark!(year2019, day20); |
175 | | - benchmark!(year2019, day21); |
176 | | - benchmark!(year2019, day22); |
177 | | - benchmark!(year2019, day23); |
178 | | - benchmark!(year2019, day24); |
179 | | - benchmark!(year2019, day25); |
180 | | -} |
| 64 | +benchmark!(year2019 |
| 65 | + day01, day02, day03, day04, day05, day06, day07, day08, day09, day10, day11, day12, day13, |
| 66 | + day14, day15, day16, day17, day18, day19, day20, day21, day22, day23, day24, day25 |
| 67 | +); |
181 | 68 |
|
182 | | -mod year2020 { |
183 | | - benchmark!(year2020, day01); |
184 | | - benchmark!(year2020, day02); |
185 | | - benchmark!(year2020, day03); |
186 | | - benchmark!(year2020, day04); |
187 | | - benchmark!(year2020, day05); |
188 | | - benchmark!(year2020, day06); |
189 | | - benchmark!(year2020, day07); |
190 | | - benchmark!(year2020, day08); |
191 | | - benchmark!(year2020, day09); |
192 | | - benchmark!(year2020, day10); |
193 | | - benchmark!(year2020, day11); |
194 | | - benchmark!(year2020, day12); |
195 | | - benchmark!(year2020, day13); |
196 | | - benchmark!(year2020, day14); |
197 | | - benchmark!(year2020, day15); |
198 | | - benchmark!(year2020, day16); |
199 | | - benchmark!(year2020, day17); |
200 | | - benchmark!(year2020, day18); |
201 | | - benchmark!(year2020, day19); |
202 | | - benchmark!(year2020, day20); |
203 | | - benchmark!(year2020, day21); |
204 | | - benchmark!(year2020, day22); |
205 | | - benchmark!(year2020, day23); |
206 | | - benchmark!(year2020, day24); |
207 | | - benchmark!(year2020, day25); |
208 | | -} |
| 69 | +benchmark!(year2020 |
| 70 | + day01, day02, day03, day04, day05, day06, day07, day08, day09, day10, day11, day12, day13, |
| 71 | + day14, day15, day16, day17, day18, day19, day20, day21, day22, day23, day24, day25 |
| 72 | +); |
209 | 73 |
|
210 | | -mod year2021 { |
211 | | - benchmark!(year2021, day01); |
212 | | - benchmark!(year2021, day02); |
213 | | - benchmark!(year2021, day03); |
214 | | - benchmark!(year2021, day04); |
215 | | - benchmark!(year2021, day05); |
216 | | - benchmark!(year2021, day06); |
217 | | - benchmark!(year2021, day07); |
218 | | - benchmark!(year2021, day08); |
219 | | - benchmark!(year2021, day09); |
220 | | - benchmark!(year2021, day10); |
221 | | - benchmark!(year2021, day11); |
222 | | - benchmark!(year2021, day12); |
223 | | - benchmark!(year2021, day13); |
224 | | - benchmark!(year2021, day14); |
225 | | - benchmark!(year2021, day15); |
226 | | - benchmark!(year2021, day16); |
227 | | - benchmark!(year2021, day17); |
228 | | - benchmark!(year2021, day18); |
229 | | - benchmark!(year2021, day19); |
230 | | - benchmark!(year2021, day20); |
231 | | - benchmark!(year2021, day21); |
232 | | - benchmark!(year2021, day22); |
233 | | - benchmark!(year2021, day23); |
234 | | - benchmark!(year2021, day24); |
235 | | - benchmark!(year2021, day25); |
236 | | -} |
| 74 | +benchmark!(year2021 |
| 75 | + day01, day02, day03, day04, day05, day06, day07, day08, day09, day10, day11, day12, day13, |
| 76 | + day14, day15, day16, day17, day18, day19, day20, day21, day22, day23, day24, day25 |
| 77 | +); |
237 | 78 |
|
238 | | -mod year2022 { |
239 | | - benchmark!(year2022, day01); |
240 | | - benchmark!(year2022, day02); |
241 | | - benchmark!(year2022, day03); |
242 | | - benchmark!(year2022, day04); |
243 | | - benchmark!(year2022, day05); |
244 | | - benchmark!(year2022, day06); |
245 | | - benchmark!(year2022, day07); |
246 | | - benchmark!(year2022, day08); |
247 | | - benchmark!(year2022, day09); |
248 | | - benchmark!(year2022, day10); |
249 | | - benchmark!(year2022, day11); |
250 | | - benchmark!(year2022, day12); |
251 | | - benchmark!(year2022, day13); |
252 | | - benchmark!(year2022, day14); |
253 | | - benchmark!(year2022, day15); |
254 | | - benchmark!(year2022, day16); |
255 | | - benchmark!(year2022, day17); |
256 | | - benchmark!(year2022, day18); |
257 | | - benchmark!(year2022, day19); |
258 | | - benchmark!(year2022, day20); |
259 | | - benchmark!(year2022, day21); |
260 | | - benchmark!(year2022, day22); |
261 | | - benchmark!(year2022, day23); |
262 | | - benchmark!(year2022, day24); |
263 | | - benchmark!(year2022, day25); |
264 | | -} |
| 79 | +benchmark!(year2022 |
| 80 | + day01, day02, day03, day04, day05, day06, day07, day08, day09, day10, day11, day12, day13, |
| 81 | + day14, day15, day16, day17, day18, day19, day20, day21, day22, day23, day24, day25 |
| 82 | +); |
265 | 83 |
|
266 | | -mod year2023 { |
267 | | - benchmark!(year2023, day01); |
268 | | - benchmark!(year2023, day02); |
269 | | - benchmark!(year2023, day03); |
270 | | - benchmark!(year2023, day04); |
271 | | - benchmark!(year2023, day05); |
272 | | - benchmark!(year2023, day06); |
273 | | - benchmark!(year2023, day07); |
274 | | - benchmark!(year2023, day08); |
275 | | - benchmark!(year2023, day09); |
276 | | - benchmark!(year2023, day10); |
277 | | - benchmark!(year2023, day11); |
278 | | - benchmark!(year2023, day12); |
279 | | - benchmark!(year2023, day13); |
280 | | - benchmark!(year2023, day14); |
281 | | - benchmark!(year2023, day15); |
282 | | - benchmark!(year2023, day16); |
283 | | - benchmark!(year2023, day17); |
284 | | - benchmark!(year2023, day18); |
285 | | - benchmark!(year2023, day19); |
286 | | - benchmark!(year2023, day20); |
287 | | - benchmark!(year2023, day21); |
288 | | - benchmark!(year2023, day22); |
289 | | - benchmark!(year2023, day23); |
290 | | - benchmark!(year2023, day24); |
291 | | - benchmark!(year2023, day25); |
292 | | -} |
| 84 | +benchmark!(year2023 |
| 85 | + day01, day02, day03, day04, day05, day06, day07, day08, day09, day10, day11, day12, day13, |
| 86 | + day14, day15, day16, day17, day18, day19, day20, day21, day22, day23, day24, day25 |
| 87 | +); |
293 | 88 |
|
294 | | -mod year2024 { |
295 | | - benchmark!(year2024, day01); |
296 | | - benchmark!(year2024, day02); |
297 | | - benchmark!(year2024, day03); |
298 | | - benchmark!(year2024, day04); |
299 | | - benchmark!(year2024, day05); |
300 | | - benchmark!(year2024, day06); |
301 | | - benchmark!(year2024, day07); |
302 | | - benchmark!(year2024, day08); |
303 | | - benchmark!(year2024, day09); |
304 | | - benchmark!(year2024, day10); |
305 | | - benchmark!(year2024, day11); |
306 | | - benchmark!(year2024, day12); |
307 | | -} |
| 89 | +benchmark!(year2024 |
| 90 | + day01, day02, day03, day04, day05, day06, day07, day08, day09, day10, day11, day12 |
| 91 | +); |
0 commit comments