Discussion

Ask HN: Why is Rust faster than C++ for calculating the sum of 1M numbers?

I did a benchmark of Rust, C++, Go, Node, Python, Ruby, etc to understand the execution time of a program that simply calculates the sum of 1 million numbers starting with 1. While C++ took around 3.5ms, Rust completed it in under 50ns. What could have been the reason why Rust performed significantly faster?

Full results can be viewed at - https://anands.me/blog/benchmarking-rust-go-cpp-node

10 points anandnair 3 years ago 13 comments

Discussion

Live from the official Hacker News API

A modern reader for Hacker News · SvelteKit + Skeleton