Skip to content

ambeckley/ComparingCandRustQuicksort

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

17 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

ComparingCandRustQuicksort

A performance comparison between the C and Rust implementations of the classic QuickSort algorithm.

Full article explaining the process can be found here: Measuring the Execution Times of C Versus Rust.

Overview

This repository contains two implementations of the QuickSort algorithm: one written in C and the other in Rust. The goal of this project is to compare the performance, of QuickSort in these two languages.

Key Features

  • C Implementation: A traditional C implementation of the QuickSort algorithm.
  • Rust Implementation: A modern, memory-safe implementation of QuickSort in Rust.
  • Performance Benchmarking: Testing the speed of sorting a random list of numbers.

Setup and Installation

gcc -shared -o libquicksort.so -fPIC -O3 -march=native -flto -funroll-loops quicksort.c
cargo new quicksort --lib

Then add the code from lib.rs and use the Cargo.toml

cargo build --release
python test.py

Prerequisites

  • C Compiler: Make sure you have a C compiler installed, such as GCC or Clang.
  • Rust Toolchain: Install the Rust programming language via rustup.
  • Benchmarking Tools: Python

Results

C was generally 10% faster than Rust.

About

Comparing C and Rust Quicksort library in python

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors