C vs Rust vs Go: performance analysis

Marek Michalik
Jul 17 · 4 min read

The Problem

The Solution

Obvious optimization

O(n) = n
O(n) = 1


Let’s run some tests

for i in 0..100000 {
C     14s
Rust 21s
Go 370s

Problem with Go

for i := 0; i < 100000; i++ {
color_extractor.ExtractColors(width, height, image)

Final results

C    14s
Rust 21s
Go 34s


Marek Michalik

Written by

Backend Engineer at Brainly

Welcome to a place where words matter. On Medium, smart voices and original ideas take center stage - with no ads in sight. Watch
Follow all the topics you care about, and we’ll deliver the best stories for you to your homepage and inbox. Explore
Get unlimited access to the best stories on Medium — and support writers while you’re at it. Just $5/month. Upgrade