{"id":16756444,"url":"https://github.com/ly0va/sort-bench","last_synced_at":"2026-04-08T20:51:15.915Z","repository":{"id":38312213,"uuid":"250611165","full_name":"ly0va/sort-bench","owner":"ly0va","description":"Sorting benchmarks of compiled languages","archived":false,"fork":false,"pushed_at":"2022-06-07T10:00:27.000Z","size":60,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-10-19T14:27:24.055Z","etag":null,"topics":["benchmark","cpp","golang","mergesort","rust"],"latest_commit_sha":null,"homepage":"","language":"Jupyter Notebook","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/ly0va.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2020-03-27T18:16:45.000Z","updated_at":"2022-06-07T10:00:22.000Z","dependencies_parsed_at":"2022-08-17T15:55:39.651Z","dependency_job_id":null,"html_url":"https://github.com/ly0va/sort-bench","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/ly0va/sort-bench","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ly0va%2Fsort-bench","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ly0va%2Fsort-bench/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ly0va%2Fsort-bench/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ly0va%2Fsort-bench/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/ly0va","download_url":"https://codeload.github.com/ly0va/sort-bench/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ly0va%2Fsort-bench/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":31573788,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-04-08T14:31:17.711Z","status":"ssl_error","status_checked_at":"2026-04-08T14:31:17.202Z","response_time":54,"last_error":"SSL_connect returned=1 errno=0 peeraddr=140.82.121.5:443 state=error: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"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","cpp","golang","mergesort","rust"],"created_at":"2024-10-13T03:25:55.008Z","updated_at":"2026-04-08T20:51:15.851Z","avatar_url":"https://github.com/ly0va.png","language":"Jupyter Notebook","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Sorting Benchmarks\n\nThese are speed benchmarks of merge sort algorithm implemented in Rust, C++ and Go.\n\nThe goal was to compare speed and efficiency of optimizations done by 3 most popular compiled\nlanguages. The algorithm implementations in all 3 languages are kept as similar as possible by the means of said languages.\nAs a reference point, results are compared to those of the built-in sort versions (which, however, implement algorithms other than merge sort).\n\n## Installation\n\nDependencies: \n\n- GNU Make\n- GNU g++\n- libpthread\n- openmp\n- rust suite (cargo, rustc, etc.)\n- go\n\n```bash\ngit clone https://github.com/ly0va/sort-bench.git\ncd sort-bench\nmake\n```\n\n## Results\n\n**Benchmark setup:**\n\n1. Each configuration was ran 25 times (to reduce the error) against an array of 100 million `int`s.\n\n2. For each language, arrays are generated randomly, with a fixed seed.\n\n3. Sequential fallback was implemented, meaning that parallel implementations use sequential ones, once array size is small enough, 2\u003csup\u003e13\u003c/sup\u003e here. \n   Without it, programs take much, MUCH longer to finish (since they spawn so many threads), and in the case of Go, freeze my computer and do not finish at all.\n\n4. CPU: Intel i5-3320M (4 cores) @ 3.3GHz\n\n5. OS: Arch Linux (kernel version 5.5)\n\n| Implementation | C++ | Rust | Go |\n| --- | --- | --- | --- |\n| Single-threaded  | 16.16s | 20.12s | 20.69s |\n| Multi-threaded   | 9.86s  | 10.34s | 10.00s |\n| Built-in         | 9.00s  | 8.82s  | 30.29s |\n| Built-in parallel | 3.21s | 4.25s  | --     |\n\n![Bar Chart](./chart.png)\n\n## Conclusions\n\n1. Go's built-in sort is weirdly slow.\n2. If not using Go, you are better off with a built-in implementation.\n3. It is good to utilize all of your cores.\n4. Unfortunately, sequential fallbacks are still necessary everywhere.\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fly0va%2Fsort-bench","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fly0va%2Fsort-bench","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fly0va%2Fsort-bench/lists"}