Skip to main content
Andrea's user avatar
Andrea's user avatar
Andrea's user avatar
Andrea
  • Member for 12 years, 5 months
  • Last seen more than 4 years ago
awarded
awarded
awarded
awarded
awarded
awarded
awarded
awarded
awarded
accepted
comment
K-Means in Rust
It turns out that cargo run --release does the trick! What I was doing was cargo build --release and then target/kmeans. Is there a way to build with optimizations on, instead of relying on Cargo to run the program?
comment
K-Means in Rust
Turns out, this implementation is even slower than the previous one. On my laptop, this implementation runs in 1807ms. You can see the whole Rust implementation, as well as a few other languages, at github.com/andreaferretti/kmeans
comment
K-Means in Rust
Thank you very much! I was suspecting that the use of a TreeMap was the culprit, but I was unable to implement Hash for Point. I understand the issues of floating point arithmetic, but still being able to group points by their nearest neighbour seems a quite reasonable task for which a hashmap is definitely desired. In fact, your solution requires the use of unsafe code, which is unexpected for this task! I will try this implementation on the same laptop I have used for the other benchmarks and let you know the time
comment
K-Means in Rust
@Shepmaster For 100000 points, 10 clusters, 15 iterations, averaged over 100 repetitions, I get 1036 ms for Scala and 1373 ms for Rust. Since then, I also tried Pypy, which got an amazing 721 ms
awarded
revised
K-Means in Rust
added 1511 characters in body
Loading…
asked
Loading…
awarded
awarded
comment
Handling parsing failure in Scala without exceptions
Thank you for the edit. Probably a more capable library like lift-json is the way to go. Just to be sure, though, I actually know the types I want to get. What I do not know is whether the JSON conforms to the format - in theory it should, but I am adding error handling for a reason! :-)