This repository contains 10 performance benchmark programs implemented in Python and Rust.
The goal is to compare execution speed, memory efficiency, and concurrency capabilities between Python and Rust in different scenarios.
- Compare recursive vs iterative Fibonacci number calculation.
- Tests stack usage & recursion performance.
- Generate prime numbers up to N.
- Useful for CPU-bound number crunching.
- Compare recursive sorting algorithms.
- Good for memory-intensive workloads.
- Implement naive O(n³) matrix multiplication.
- Optimized version uses loop reordering / blocking.
- Numerical computing performance test.
- Write large text files, read them, and count words.
- Compares I/O speed and string manipulation.
- Serialize and parse JSON data.
- Python →
json - Rust →
serde_json
- Sum of numbers using:
- Python → Multithreading (GIL-limited) & Multiprocessing
- Rust → True multithreading + multiprocessing
- Insert, search, and delete 1,000,000 key-value pairs.
- Compare performance of Python
dictvs RustHashMap.
- Implement Dijkstra’s shortest path.
- Compare graph traversal efficiency.
- Python →
requests + BeautifulSoup - Rust →
reqwest + scraper - Extract links from a webpage.
- Python 3.10+
- Required libraries:
pip install requests beautifulsoup4
- Rust 1.80+
- Required crates (added via cargo add):
cargo add rand cargo add serde_json cargo add reqwest cargo add scraper cargo add tokio --features full
- Rust is consistently faster in CPU-bound tasks, recursion, and multithreading.
- Python is easier to write and has powerful libraries, but suffers from the GIL and slower execution.
This repo is a learning experiment to demonstrate how both languages handle common workloads.
Created by Mohammad Amin ✨