{"id":26742397,"url":"https://github.com/soulwax/heapsort-performance-measurement-tools","last_synced_at":"2026-04-28T11:34:10.209Z","repository":{"id":284711070,"uuid":"955811255","full_name":"soulwax/Heapsort-Performance-Measurement-Tools","owner":"soulwax","description":"Heapsort algorithm, implemented from scratch, benchmark results and plot estimated time complexity.","archived":false,"fork":false,"pushed_at":"2025-03-27T10:50:34.000Z","size":686,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-03-27T11:39:00.336Z","etag":null,"topics":["benchmark","c","heapsort","python","sorting-algorithms","time-complexity","visualization"],"latest_commit_sha":null,"homepage":"","language":"C","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/soulwax.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2025-03-27T08:32:43.000Z","updated_at":"2025-03-27T10:50:38.000Z","dependencies_parsed_at":"2025-03-27T11:49:09.962Z","dependency_job_id":null,"html_url":"https://github.com/soulwax/Heapsort-Performance-Measurement-Tools","commit_stats":null,"previous_names":["soulwax/heapsort-file","soulwax/heapsort-performance-measurement-tools"],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/soulwax%2FHeapsort-Performance-Measurement-Tools","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/soulwax%2FHeapsort-Performance-Measurement-Tools/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/soulwax%2FHeapsort-Performance-Measurement-Tools/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/soulwax%2FHeapsort-Performance-Measurement-Tools/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/soulwax","download_url":"https://codeload.github.com/soulwax/Heapsort-Performance-Measurement-Tools/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":245978283,"owners_count":20703678,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["benchmark","c","heapsort","python","sorting-algorithms","time-complexity","visualization"],"created_at":"2025-03-28T06:17:46.890Z","updated_at":"2026-04-28T11:34:10.165Z","avatar_url":"https://github.com/soulwax.png","language":"C","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Heapsort + Performance Measurement Tools\n\nThis project implements a heapsort algorithm with comprehensive performance measurement tools, as well as a random number generator utility. It includes features for timing sort operations, conducting benchmarks, and visualizing algorithm performance.\n\n## Table of Contents\n\n- [Basic Usage](#basic-usage)\n- [Using the Programs](#using-the-programs)\n  - [Heapsort](#for-heapsort)\n  - [Random Number Generator](#for-genrand_f)\n- [Performance Measurement](#performance-measurement)\n  - [Timing Output](#timing-output)\n  - [Benchmark Utility](#benchmark-utility)\n  - [Visualization Tools](#visualization-tools)\n- [Benchmark Results](#benchmark-results)\n- [Makefile Commands](#makefile-commands)\n- [VS Code Integration](#vs-code-integration)\n\n## Basic Usage\n\n1. **Build all programs**:\n\n   ```sh\n   make\n   ```\n\n2. **Build specific programs**:\n\n   ```sh\n   make heapsort\n   make genrand_f\n   make benchmark\n   ```\n\n3. **Clean the build**:\n\n   ```sh\n   make clean\n   ```\n\n## Using the Programs\n\n### For heapsort\n\n1. **Sort numbers directly from command line**:\n\n   ```sh\n   ./bin/heapsort 5 2 9 1 7 4\n   ```\n\n2. **Sort numbers from an input file**:\n\n   ```sh\n   ./bin/heapsort -f input/randnum_fixed.txt\n   ```\n\n3. **Sort and save to output file**:\n\n   ```sh\n   ./bin/heapsort -f input/randnum_fixed.txt -o sorted.txt\n   ```\n\n4. **Time-only mode (for benchmarking)**:\n\n   ```sh\n   ./bin/heapsort -f input/randnum_fixed.txt --time-only\n   ```\n\n   This outputs only the sorting time, useful for benchmarking.\n\n### For genrand_f\n\n1. **Generate default random numbers** (100 numbers between 1-1000):\n\n   ```sh\n   ./bin/genrand_f\n   ```\n\n2. **Generate a specific number of random values**:\n\n   ```sh\n   ./bin/genrand_f -c 500\n   ```\n\n3. **Specify range for random numbers**:\n\n   ```sh\n   ./bin/genrand_f -c 200 -min -100 -max 100\n   ```\n\n## Performance Measurement\n\nThe project includes comprehensive tools for measuring and analyzing the performance of the heapsort algorithm.\n\n### Timing Output\n\nAll sort operations automatically include timing information that measures **only the sorting algorithm** (not file I/O or other operations). The time is displayed in appropriate units (ns, μs, ms, or s) based on the magnitude:\n\n```plaintext\nSorting algorithm performance: Sorted 1000 items in 1.25 ms\n```\n\n### Benchmark Utility\n\nThe benchmark utility tests heapsort performance across a range of array sizes:\n\n1. **Run benchmark with default settings**:\n\n   ```sh\n   make run-benchmark\n   ```\n\n   This tests array sizes from 1,000 to 100,000 elements in steps of 10,000.\n\n2. **Run custom benchmark**:\n\n   ```sh\n   make run-custom-benchmark\n   ```\n\n   This runs a custom benchmark with different size ranges and steps.\n\n3. **Specify custom benchmark parameters**:\n\n   ```sh\n   ./bin/benchmark --min 500 --max 10000 --step 500 --repeats 5\n   ```\n\n   Parameters:\n   - `--min`: Minimum array size\n   - `--max`: Maximum array size\n   - `--step`: Size increment between benchmarks\n   - `--repeats`: Number of repetitions for each size (for more accurate measurements)\n\nBenchmark results are saved to CSV files in the `benchmark_results` directory.\n\n### Visualization Tools\n\nA Python script is included to visualize benchmark results:\n\n```sh\npython3 visualize_benchmark.py\n```\n\nThis creates three visualizations in the `benchmark_plots` directory:\n\n1. **Sort Time Plot**: Shows sorting time vs. array size\n2. **Log-Log Plot**: Log-log scale plot to help identify algorithmic complexity\n3. **Complexity Analysis**: Curve fitting to determine the algorithm's time complexity\n\n## Benchmark Results\n\nBelow are sample visualizations of the HeapSort algorithm performance based on benchmark data:\n\n### Sort Time Plot\n\nThis plot shows the direct relationship between array size and sorting time in milliseconds.\n\n![Sort Time Plot](benchmark_plots/heapsort_benchmark_1000_100000_sort_time.png)\n\n### Logarithmic Scale Analysis\n\nThis log-log plot helps visualize the algorithmic complexity by comparing the actual performance against reference complexity lines (O(n), O(n log n), O(n²)).\n\n![Log-Log Plot](benchmark_plots/heapsort_benchmark_1000_100000_loglog.png)\n\n### Complexity Analysis\n\nThis analysis uses curve fitting to determine which complexity class best describes the algorithm's performance. As expected for HeapSort, the O(n log n) curve typically provides the best fit.\n\n![Complexity Analysis](benchmark_plots/heapsort_benchmark_1000_100000_complexity.png)\n\n## Makefile Commands\n\nIn addition to the basic commands, the Makefile includes:\n\n```sh\n# Build the benchmark utility\nmake benchmark\n\n# Run benchmark with default settings\nmake run-benchmark\n\n# Run benchmark with custom settings\nmake run-custom-benchmark\n\n# Clean all generated files\nmake clean\n```\n\n## VS Code Integration\n\nThe project includes VS Code configuration files in the `.vscode` directory:\n\n- **tasks.json**: Defines build and benchmark tasks\n- **launch.json**: Configures debugging for all programs\n- **c_cpp_properties.json**: Sets up IntelliSense for C/C++\n- **settings.json**: Additional editor settings\n\nTo use the VS Code integration:\n\n1. Open the project folder in VS Code\n2. Press `Ctrl+Shift+B` (or `Cmd+Shift+B` on Mac) to build\n3. Press `F5` to run with debugging\n4. Use the Run and Debug panel to select different launch configurations\n5. Use the Terminal menu to execute tasks like benchmarking\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsoulwax%2Fheapsort-performance-measurement-tools","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fsoulwax%2Fheapsort-performance-measurement-tools","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsoulwax%2Fheapsort-performance-measurement-tools/lists"}