Skip to content

JustCabaret/ArraySortingBenchmark

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

15 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Array Sorting Benchmark

A Python sandbox environment designed to benchmark and compare the performance and physical energy consumption of different sorting algorithms.

Why I updated it

In earlier versions, CPU energy tracking was calculated using an unreliable 1-second threading poll that outputted an abstract score. Furthermore, algorithms were forced to load the dataset from the disk during their benchmark runs. This meant I was measuring disk I/O latency instead of the actual efficiency of the mathematical sorting logic.

This updated version was heavily refactored to focus on hardware truth:

  • Physics over Abstract Scores: The main engine now dynamically profiles your host PC (identifying the CPU architecture), estimates the maximum TDP in Watts, and outputs actual energy costs in Joules, based strictly on core utilization and synchronous execution time.
  • Pure Isolation: Arrays are loaded and copied in RAM before the timers run. Zero disk I/O bottleneck overheads.
  • Extensible Plugin System: You no longer need to edit the engine logic to add a new sorting function. Anything placed in the sorters/ directory is automatically imported and tested.

Getting Started

1. Requirements

Ensure you have Python 3 installed, then install the required tracking libraries:

pip install numpy matplotlib psutil

2. Running the Engine

To start the testing pipeline, execute the main file:

python energy_counter.py

If you don't have the dataset generated yet, the script will automatically create a testing package (random_words_array.npy) containing 1,000,000 random words to use as the baseline.

Adding Custom Algorithms

The system is entirely decoupled. To add your own algorithm, just drop a Python file into the sorters/ directory following a simple contract.

Example sorters/your_algorithm.py:

NAME = "My Custom Sort"

def sort(arr):
    # Perform your sorting logic
    return arr

The next time you start the benchmark, the script will passively discover your file, run it, and place it on the final grid alongside the default ones.

The Dashboard

When the benchmark completes, a grid-based darkmode dashboard will render the results side-by-side, specifically focused on:

  • Execution Time (Seconds)
  • Active CPU Cores Utilized
  • Memory Consumption (MB)
  • Physical Energy Cost (Joules)

License

This project is licensed under the MIT License - see the LICENSE file for details. Built originally with the help of @Bita05.

About

Benchmark and compare array sorting algorithms with performance metrics.

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages