Skip to content

Commit

Permalink
docs(2023): add note on performance increase day 8
Browse files Browse the repository at this point in the history
  • Loading branch information
believer committed Dec 8, 2023
1 parent 0e9320b commit b0e9954
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 1 deletion.
2 changes: 1 addition & 1 deletion rust/2023/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -50,4 +50,4 @@ With the help of [cargo-aoc](https://github.com/gobanos/cargo-aoc) I get automat
| 3 | 172.23 µs | - | Baseline | [Link](https://github.com/believer/advent-of-code/blob/75a83e31024bbac99a0664f81fce4e13ec1e94af/rust/2023/src/day_03.rs) |
| 4 | 24.33 µs | 24.32 µs | Baseline | [Link](https://github.com/believer/advent-of-code/blob/c970c6322d3904048bcf3f30b1052e2916476d73/rust/2023/src/day_04.rs) |
| 5 | 1.50 µs | 21.22 s | Baseline | [Link](https://github.com/believer/advent-of-code/blob/39b0904c4921f4ae79963a6df49bb3502ef6b3be/rust/2023/src/day_05.rs) |
| 8 | - | 15.25 ms | Baseline | [Link](https://github.com/believer/advent-of-code/blob/4b96f6e935734f657469b091072282f1c430bcd3/rust/2023/src/day_08.rs) |
| 8 | - | 15.25 ms | Baseline | [Link](https://github.com/believer/advent-of-code/blob/912d70c6e04ffd97f766c79b90764c105fe2f6ce/rust/2023/src/day_08.rs) |
6 changes: 6 additions & 0 deletions rust/2023/src/day_08.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,12 @@ use std::collections::HashMap;
// it would just loop. This meant that we can calculate the steps for each
// start location, and then find the least common multiple of all the steps.
// The answer turned out to be _huge_, so no real way of brute forcing it.
//
// It turns out the when I refactored to using the Direction enum, I also gained
// a huge performance boost. About 70% faster. I think it's because I could
// change getting directions using chars().nth(index) to just directions.get(index)
// in two places inside the loop. I didn't run the benchmarks after that change.
// I had no idea that it would make that much of a difference.

#[derive(Debug)]
enum Direction {
Expand Down

0 comments on commit b0e9954

Please sign in to comment.