rust-vs-go/README.md
2023-03-16 17:11:33 -05:00

1008 B

Rust vs Go

This repository contains two quick implementations of echo servers in both [Rust] and [Go]. Both are great languages with lots of support, I wanted to take a look at the type of operations that our programs will be performing to get an idea of how well each will perform.

Running the Rust server

cd rust
cargo run src/main.rs
# Listening on http://127.0.0.1:3000

Running the Go server

cd go
go run main.go
# Listening on 127.0.0.1:3001

Testing the servers

# 2MiB
RAND_CHARS=$(( 2 * 1024 * 1024 ))

# send requests to Rust
time bash -c 'tr -dc A-Za-z0-9 </dev/urandom | head -c $RAND_CHARS | curl -X POST -d@- http://localhost:3000'
# ... bash -c   0.04s user 0.05s system 7% cpu 1.114 total

# send requests to Go
time bash -c 'tr -dc A-Za-z0-9 </dev/urandom | head -c $RAND_CHARS | curl -X POST -d@- http://localhost:3001'
# ... bash -c   0.04s user 0.05s system 84% cpu 0.114 total

Rust has a noticably longer echo time when compared to Go.