My Rust AOC solution gets beaten by the same version in Javascript by factor 10? Can you help me with increasing my performance?
AOC 2022 day 16
- JS Part 1 = \~110ms (https://github.com/hammerlink/adventofcode/blob/master/src/2022/y2022\_day16.ts)
- Rust Part 1 = \~160 ms (https://github.com/hammerlink/adventofcode/blob/master/aoc-2022-rust/src/days/day\_16/main\_16.rs)
EDIT: I was not running in release mode, in release mode it was only 50% slower! (1100 ms -> 160ms)
\- improvement by u/phazer99 preventing cloning my valve list: 160 ms ->140ms
\- improvement by u/jDomantas using FxHashMap instead of HashMap: 140ms -> \~130ms
\- improvement by u/jDomantas using &str in the ValveIteration reduced it to under a 100ms!! JS is beaten :D
The algorithm of my solution is certainly non optimal. I implemented the same algorithm in both languages, which makes it ideal for comparison.
(PS I am using AOC to learn the rust language, please don't roast me to hard if I am doing stupid stuff)
Screenshot of the profiler of Rust Day 16 part 1