Performance of Rust versus C

I am a beginner of Rust.

Rust is described as "fast and memory-efficient" of its performance, but why the exe file seems not like this?


#include "stdio.h"
int main() {
    printf("Hello, world!\n");
    return 0;


fn main() {
    println!("Hello, world!");

My compiler is MinGW-gcc. The size of the exe file compiled from main.c is 53k, but that from is 3474k in release mode. How should I look at the performance of Rust versus C?

Benchmark and measure (not the file size, but working memory etc).

For explanation about the file size difference look up dynamic vs static linking.


I don't think binary size is usually included when considering performance, though it can of course be a relevant metric to consider in some contexts. The bulk of the difference is due to Rust binaries being statically linked, I believe. This blog post is a few years old, but still relevant I think:


If binary size is a concern, I recommend you acquaint yourself with this github repo:


If you want to have small binaries you can give UPX( a chance. But please be careful if execution performance and RAM usage. But it creates small binaries with a cost of higher starting time and its using more RAM.

1 Like

Thanks for all replies. I think your answer @Heliozoa is exactly what I want, thanks again.

1 Like

This topic was automatically closed 90 days after the last reply. We invite you to open a new topic if you have further questions or comments.