My Rust AOC solution gets beaten by the same version in Javascript by factor 10? Can you help me with increasing my performance?

118 points hammerchecker

AOC 2022 day 16

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

https://preview.redd.it/n0eyztyt9pwb1.png?width=2308&format=png&auto=webp&s=df5a203ea93b21ef9f713358ae40c9f67a4a0c04