{"id":15893285,"url":"https://github.com/nunofachada/sorttest_c","last_synced_at":"2025-07-14T03:35:04.613Z","repository":{"id":74270397,"uuid":"49155017","full_name":"nunofachada/sorttest_c","owner":"nunofachada","description":"Self-contained ANSI C program for testing sorting algorithms","archived":false,"fork":false,"pushed_at":"2016-01-07T16:12:43.000Z","size":5,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-02-08T08:15:26.653Z","etag":null,"topics":["benchmarking","bubble-sort","c","mergesort","quicksort","selection-sort","selectionsort","sorting-algorithms"],"latest_commit_sha":null,"homepage":null,"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/nunofachada.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}},"created_at":"2016-01-06T18:55:04.000Z","updated_at":"2016-01-06T18:55:33.000Z","dependencies_parsed_at":"2023-03-17T08:00:47.315Z","dependency_job_id":null,"html_url":"https://github.com/nunofachada/sorttest_c","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/nunofachada%2Fsorttest_c","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/nunofachada%2Fsorttest_c/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/nunofachada%2Fsorttest_c/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/nunofachada%2Fsorttest_c/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/nunofachada","download_url":"https://codeload.github.com/nunofachada/sorttest_c/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":246863638,"owners_count":20846290,"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":["benchmarking","bubble-sort","c","mergesort","quicksort","selection-sort","selectionsort","sorting-algorithms"],"created_at":"2024-10-06T08:09:43.619Z","updated_at":"2025-04-02T17:41:24.463Z","avatar_url":"https://github.com/nunofachada.png","language":"C","readme":"### Self-contained ANSI C program for benchmarking sorting algorithms\n\n#### Compiling\n\nUsing [GCC]:\n\n```\ngcc sorttest.c -ansi -Wall -pedantic -o sorttest\n```\n\nUsing [clang]:\n\n```\nclang sorttest.c -ansi -Wall -pedantic -o sorttest\n```\n\nUsing [Microsoft Visual Studio C compiler][vscc]:\n\n```\ncl sorttest.c\n```\n\n#### Usage\n\n```\n./sorttest SORTALG NUM SEED [CHECK]\n    SORTALG - Sorting algorithm: bubble, selection, merge, quick\n        NUM - Number of elements to sort\n       SEED - Seed for random number generator\n      CHECK - Check if sorting is correct\n```\n\nFor example, invoking `sorttest` to sort an integer array of 100,000 elements\nusing Bubble sort and a random number generator seed of 99823:\n\n```\n$ ./sorttest bubble 100000 99823\n```\n\nIf a 4th argument is given, the program checks the correctness of the sorting\nprocedure:\n\n```\n$ ./sorttest bubble 100000 34545 yes\nSorting Ok!\n```\n\n#### Benchmarking with GNU Time\n\nIn several Linux OSes the [GNU Time] utility must be explicitly installed using\nthe package manager and invoked as `/usr/bin/time`. On OSX it should be\ninstalled using [Homebrew] or similar, and it is invoked as `gtime`.\n\nIt is also possible to use the shell built-in *time* command, which is available\nby default on Linux and OSX. For Windows, [Cygwin] and [MinGW] provide a [Bash]\nshell with this command, but there are [native alternatives].\n\n##### Default output format\n\nThe [PerfAndPubTools] benchmark analysis functions accept the default output\nformat of the [GNU Time] command, as shown in the following example:\n\n```\n$ /usr/bin/time ./sorttest merge 500000 99823\n0.18user 0.00system 0:00.18elapsed 99%CPU (0avgtext+0avgdata 7076maxresident)k\n0inputs+0outputs (0major+2655minor)pagefaults 0swaps\n```\n\nOf course, the output should be redirected to a file in order to be used by\n[PerfAndPubTools]:\n\n```\n$ /usr/bin/time ./sorttest quick 1000000 2362 2\u003e time.txt \n```\n\n##### Alternative output formats\n\nThe `-f` option allows to format the output of the [GNU Time] command. For\nexample, the `%e` format specifier shows the elapsed wall clock time used by the\nprocess (in seconds), while the `%M` specifier displays the maximum resident set\nsize of the process during its lifetime, in Kilobytes. These are useful for\ntesting the time and space complexity of each algorithm:\n\n```\n$ /usr/bin/time -f \"%e sec.\\n%M Kb\\n\" ./sorttest bubble 100000 128\n59.62 sec.\n1348 Kb\n\n$ /usr/bin/time -f \"%e sec.\\n%M Kb\\n\" ./sorttest selection 100000 128\n16.87 sec.\n1352 Kb\n\n$ /usr/bin/time -f \"%e sec.\\n%M Kb\\n\" ./sorttest merge 100000 128\n0.03 sec.\n2320 Kb\n\n$ /usr/bin/time -f \"%e sec.\\n%M Kb\\n\" ./sorttest quick 100000 128\n0.02 sec.\n1348 Kb\n```\n\n#### License\n\n[MIT License](http://opensource.org/licenses/MIT)\n\n[GNU Time]: https://www.gnu.org/software/time/\n[Homebrew]: http://brew.sh/\n[PerfAndPubTools]: https://github.com/fakenmc/perfandpubtools\n[Cygwin]: https://www.cygwin.com/\n[MinGW]: http://www.mingw.org/\n[Bash]: http://tiswww.case.edu/php/chet/bash/bashtop.html\n[tricky]: http://stackoverflow.com/questions/13356628/is-there-a-way-to-redirect-time-output-to-file-in-linux\n[native alternatives]: http://stackoverflow.com/questions/673523/how-to-measure-execution-time-of-command-in-windows-command-line\n[GCC]: https://gcc.gnu.org/\n[clang]: http://clang.llvm.org/\n[vscc]: https://msdn.microsoft.com/en-us/library/bb384838.aspx\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fnunofachada%2Fsorttest_c","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fnunofachada%2Fsorttest_c","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fnunofachada%2Fsorttest_c/lists"}