{"id":16572756,"url":"https://github.com/lemire/simple_cpp_shuffle_benchmark","last_synced_at":"2025-06-16T21:33:55.289Z","repository":{"id":66054960,"uuid":"205926192","full_name":"lemire/simple_cpp_shuffle_benchmark","owner":"lemire","description":"Simple benchmark to see how fast the standard C++ library can shuffle arrays","archived":false,"fork":false,"pushed_at":"2020-10-09T14:30:58.000Z","size":9,"stargazers_count":5,"open_issues_count":1,"forks_count":3,"subscribers_count":4,"default_branch":"master","last_synced_at":"2025-04-09T02:51:17.028Z","etag":null,"topics":[],"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/lemire.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":"2019-09-02T19:47:53.000Z","updated_at":"2024-10-14T16:06:04.000Z","dependencies_parsed_at":null,"dependency_job_id":"bdf774b6-0584-4f17-b93b-361458f68139","html_url":"https://github.com/lemire/simple_cpp_shuffle_benchmark","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/lemire/simple_cpp_shuffle_benchmark","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/lemire%2Fsimple_cpp_shuffle_benchmark","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/lemire%2Fsimple_cpp_shuffle_benchmark/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/lemire%2Fsimple_cpp_shuffle_benchmark/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/lemire%2Fsimple_cpp_shuffle_benchmark/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/lemire","download_url":"https://codeload.github.com/lemire/simple_cpp_shuffle_benchmark/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/lemire%2Fsimple_cpp_shuffle_benchmark/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":260245130,"owners_count":22980155,"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":[],"created_at":"2024-10-11T21:28:30.315Z","updated_at":"2025-06-16T21:33:55.274Z","avatar_url":"https://github.com/lemire.png","language":"C++","funding_links":[],"categories":[],"sub_categories":[],"readme":"# simple_cpp_shuffle_benchmark\nSimple benchmark to see how fast the standard C++ library can shuffle arrays.\n\n[The algorithm benchmarked](https://arxiv.org/abs/1805.10941) was adopted to accelerate random number generation\n  * by the [standard C++ Linux library (GNU libstdc++)](https://gcc.gnu.org/git/?p=gcc.git;a=blobdiff;f=libstdc%2B%2B-v3/include/bits/uniform_int_dist.h;h=ecb8574864aee10b9ea164379fffef27c7bdb0df;hp=6e1e3d5fc5fe8f7f22e62a85b35dc8bfa4743372;hb=98c37d3bacbb2f8bbbe56ed53a9547d3be01b66b;hpb=6ce2cb116af6e0965ff0dd69e7fd1925cf5dc68c) to accelerate the std::uniform_int_distribution function,\n * by [Google's Abseil C++ Common Libraries](https://github.com/abseil/abseil-cpp),\n * by [the Swift standard library](https://github.com/apple/swift/pull/25286),\n * by the [Go language](https://github.com/golang/go/commit/a2dfe5d278eae0864397a046a8206342a426d2bd),\n * by the  [Julia language](https://github.com/JuliaLang/julia/pull/29240),\n * by the [Zig language](https://github.com/ziglang/zig/blob/98183e47436699f6e5eab200061c46eec342806e/std/rand.zig#L74-L118),\n * and by [Numpy](https://github.com/numpy/numpy/blob/6420e7f528a6c42422966544e453bdb2805ff620/numpy/random/generator.pyx) (Python).\n\n## Requirements\n\nLinux-like system with Make and GNU GCC.\n\n\n## Usage\n\n```\n$ make\ng++ -O3 -o benchmark benchmark.cpp -std=c++11 -Wall\n$ ./benchmark\nWe benchmark arrays of 32-bit elements.\n\n void ShuffleBenchmark32(size_t, bool)\nShuffling arrays of size 1000000\nUses a Mersenne Twister pseudo-random generator of 32-bit numbers\nTime reported in number of ns per array element.\nrepeat = 10\nstd::shuffle(testvalues, testvalues + size, g)              :  27992800 ns total,  27.99 ns per input key\nwarning: average 29.627110 vs min 27.992800 (5.516265 percent) for arrays of size 1000000\n\n void ShuffleBenchmark64(size_t, bool)\nShuffling arrays of size 1000000\nUses a Mersenne Twister pseudo-random generator of 64-bit numbers\nTime reported in number of ns per array element.\nrepeat = 10\nstd::shuffle(testvalues, testvalues + size, g)              :  15834900 ns total,  15.83 ns per input key\nwarning: average 17.528509 vs min 15.834900 (9.662027 percent) for arrays of size 1000000\n```\n\n## Other code\n\nFor a large testing code base, see https://github.com/lemire/FastShuffleExperiments\n\n## Reference\n\nDaniel Lemire,  [Fast Random Integer Generation in an Interval](https://arxiv.org/abs/1805.10941), ACM Transactions on Modeling and Computer Simulation 29 (1), 2019\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Flemire%2Fsimple_cpp_shuffle_benchmark","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Flemire%2Fsimple_cpp_shuffle_benchmark","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Flemire%2Fsimple_cpp_shuffle_benchmark/lists"}