{"id":28377660,"url":"https://github.com/dietime/qqsort","last_synced_at":"2025-08-26T20:17:38.617Z","repository":{"id":189228695,"uuid":"680294380","full_name":"DieTime/qqsort","owner":"DieTime","description":"Reimplementation of qsort function from glibc with more ability to inline comparison function.","archived":false,"fork":false,"pushed_at":"2023-08-20T11:10:30.000Z","size":57,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-06-23T16:38:47.099Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"","language":"C++","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/DieTime.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE.md","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null}},"created_at":"2023-08-18T20:35:35.000Z","updated_at":"2023-08-26T21:26:19.000Z","dependencies_parsed_at":"2023-08-18T22:02:39.944Z","dependency_job_id":null,"html_url":"https://github.com/DieTime/qqsort","commit_stats":null,"previous_names":["dietime/qqsort"],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/DieTime/qqsort","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/DieTime%2Fqqsort","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/DieTime%2Fqqsort/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/DieTime%2Fqqsort/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/DieTime%2Fqqsort/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/DieTime","download_url":"https://codeload.github.com/DieTime/qqsort/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/DieTime%2Fqqsort/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":272253314,"owners_count":24900880,"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","status":"online","status_checked_at":"2025-08-26T02:00:07.904Z","response_time":60,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"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":[],"created_at":"2025-05-30T01:06:11.317Z","updated_at":"2025-08-26T20:17:38.609Z","avatar_url":"https://github.com/DieTime.png","language":"C++","funding_links":[],"categories":[],"sub_categories":[],"readme":"\u003cp align=\"center\"\u003e\n    \u003cimg src=\"assets/logo.png\" width=\"400px\" /\u003e\n\u003c/p\u003e\n\n\u003cp align=\"center\"\u003e\n    \u003cimg src=\"https://img.shields.io/github/license/DieTime/qqsort?color=%34D058\" alt=\"License: BSD 3-Clause\" /\u003e\n    \u003cimg src=\"https://img.shields.io/badge/usage-single%20header-green?color=%34D058\" alt=\"Usage Single Header\" /\u003e\n\u003c/p\u003e\n\nThe `qqsort` macro is a reimplementation of [qsort](https://codebrowser.dev/glibc/glibc/stdlib/qsort.c.html) function from glibc with more ability to inline comparison function.\n\n# Usage\n\n```c\n#include \u003cstdio.h\u003e\n#include \"qqsort.h\"\n\nint main(void) {\n    int array[] = {4, 3, 2, 1, 0, 5, 6, 7, 8, 9};\n    int size = sizeof(array) / sizeof(array[0]);\n\n    qqsort(array,\n           size,\n           sizeof(int),\n           qqsortcmp(int *a, int *b) {\n                qqsortret(*a - *b);\n           });\n\n    for (int idx = 0; idx \u003c size; idx++) {\n        printf(\"%d \", array[idx]);\n    }\n\n    return 0;\n}\n```\n\n# Benchmark\n\n\u003e ❗This project is just an experiment to study the influence of inlining on code performance.\n\nMachine used for benchmark:\n\n* AMD Ryzen 7 5800x\n* 16GB RAM\n* Linux 6.2.0\n\nFor the benchmark, a simple C++ [program](./benchmark/main.cpp) was implemented to sort an array of structures in three ways:\n\n* Sorting using `stl`\n* Sorting using the `qsort` function of the library\n* Sorting with the `qqsort` macro\n\nThree compilers were used to build the benchmark:\n\n* `g++ 11.4.0`\n* `clang++ 14.0.0`\n* `msvc 19.37`\n\nThe following compilation flags were used:\n\n```python\nCOMPILE_ARGS = [ \"-flto\", \"-O2\", ... ]\n```\n\nThe `qqsort` macro showed positive results in performance only when using the `g++` and `msvc` compilers. When using `clang++`, the `qqsort` macro performs worse than the `qsort` function.\n\n![benchmark-g++](benchmark/assets/g++.svg)\n![benchmark-msvc](benchmark/assets/msvc.svg)\n![benchmark-clang++](benchmark/assets/clang++.svg)\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdietime%2Fqqsort","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fdietime%2Fqqsort","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdietime%2Fqqsort/lists"}