Skip to content

felixTineo/rust-vs-python

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

1 Commit
 
 
 
 
 
 

Repository files navigation

Rust vs Python: Speed Benchmark

This repository contains two implementations of the same project in Rust and Python to compare their performance in calculating prime numbers.

Project Structure

├── python
   ├── main.py
   └── requirements.txt
├── README.md
└── rust
    ├── Cargo.lock
    ├── Cargo.toml
    ├── src
    └── target

Getting Started

Python Implementation

  1. Navigate to the python folder:
cd python
  1. Create and activate environment
python -m venv .env
source .env/bin/activate    # Use `.env\Scripts\activate` on Windows
  1. Install any required dependencies:
pip install -r requirements.txt
  1. Run the program
python main.py

Rust implementation

  1. Navigate to the rust folder:
cd rust
  1. Build the project
cargo run build
  1. Run the project
cargo run --release

Comparing Performance

Each implementation calculates all prime numbers up to 10 million. The time taken for execution will be printed to the console after running the programs.

Benchmarking Tools

  • Python: Execution time is measured using the built-in time module.
  • Rust: Use std::time for basic measurement, or integrate criterion for advanced benchmarking.

Contributions

Feel free to fork the repository, open issues, or submit pull requests to improve the implementations or add new comparisons.

About

Speed ​​experiment between Rust and Python.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published