Rust is so slow b/c it default to be build on debug mode. On my system (Intel i5-7600K/Fedora 37/rustc 1.69,go 1.20) the differences are very clear:
23.3s
-C opt-level=1
4.1s
-C opt-level=2
4.0s
-C opt-level=1 -C target-cpu=native
3.7s
-C opt-level=2 -C target-cpu=native
Best performance with rustc -C opt-level=1 -C target-cpu=native primes.rs
rustc -C opt-level=1 -C target-cpu=native primes.rs
For Go you need to switch to integer type uint32. On my system that brought the time down from 13s (similar to yours) to 3.6s.
uint32
13s
3.6s
Are you sure you want to hide this comment? It will become hidden in your post, but will still be visible via the comment's permalink.
Hide child comments as well
Confirm
For further actions, you may consider blocking this person and/or reporting abuse
We're a place where coders share, stay up-to-date and grow their careers.
Rust is so slow b/c it default to be build on debug mode.
On my system (Intel i5-7600K/Fedora 37/rustc 1.69,go 1.20) the differences are very clear:
23.3s, pretty much what you have-C opt-level=1it goes down to4.1s-C opt-level=2it goes down to4.0s-C opt-level=1 -C target-cpu=nativeit goes down to3.7s-C opt-level=2 -C target-cpu=nativeit goes down to4.1s.For Go you need to switch to integer type
uint32.On my system that brought the time down from
13s(similar to yours) to3.6s.