{"id":21655195,"url":"https://github.com/pseitz/binggan","last_synced_at":"2025-04-07T15:06:20.207Z","repository":{"id":235501057,"uuid":"790850233","full_name":"PSeitz/binggan","owner":"PSeitz","description":"Benchmarking library for stable Rust","archived":false,"fork":false,"pushed_at":"2024-11-06T03:06:02.000Z","size":496,"stargazers_count":33,"open_issues_count":3,"forks_count":3,"subscribers_count":2,"default_branch":"main","last_synced_at":"2025-03-31T14:15:17.403Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"Rust","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/PSeitz.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE-MIT","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":"2024-04-23T16:36:32.000Z","updated_at":"2025-03-20T20:45:24.000Z","dependencies_parsed_at":"2024-04-23T16:50:29.513Z","dependency_job_id":"13f6f74e-d164-4df1-b7d6-db4d39d6c7fb","html_url":"https://github.com/PSeitz/binggan","commit_stats":null,"previous_names":["pseitz/binggan"],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/PSeitz%2Fbinggan","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/PSeitz%2Fbinggan/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/PSeitz%2Fbinggan/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/PSeitz%2Fbinggan/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/PSeitz","download_url":"https://codeload.github.com/PSeitz/binggan/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247675596,"owners_count":20977376,"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-11-25T08:30:36.143Z","updated_at":"2025-04-07T15:06:20.184Z","avatar_url":"https://github.com/PSeitz.png","language":"Rust","funding_links":[],"categories":[],"sub_categories":[],"readme":"![Rust](https://github.com/PSeitz/binggan/workflows/Rust/badge.svg)\n[![Docs](https://docs.rs/binggan/badge.svg)](https://docs.rs/crate/binggan/)\n[![Crates.io](https://img.shields.io/crates/v/binggan.svg)](https://crates.io/crates/binggan)\n\n## Binggan\n![binggan logo](https://raw.githubusercontent.com/PSeitz/binggan/main/logo_s.png)\n\nBinggan (餅乾, bǐng gān, means cookie in Chinese) is a benchmarking library for Rust.\nIt is designed to be simple to use and to provide a good overview of the performance of your code and its memory consumption.\n\n### Features\n\n* 📊 Peak Memory Usage\n* 💎 Stack Offset Randomization\n* 🔌 Plugin System\n* 💖 Perf Integration (Linux)\n* 🔄 Delta Comparison\n* ⚡ Fast Execution\n* 🔀 Interleaving Test Runs (More accurate results)\n* 🏷️ Named Runs, Groups and Benchmarks\n* 🧙 No Macros, No Magic (Just a regular API)\n* 🦀 Runs on Stable Rust\n* 📈 Custom Reporter\n* 🧩 Report Output of Benchmarks\n* 🎨 NOW with colored output!\n\n### Example\n\n```rust\nuse binggan::{black_box, plugins::*, InputGroup, PeakMemAlloc, INSTRUMENTED_SYSTEM};\n\n#[global_allocator]\npub static GLOBAL: \u0026PeakMemAlloc\u003cstd::alloc::System\u003e = \u0026INSTRUMENTED_SYSTEM;\n\n\nfn test_vec(data: \u0026Vec\u003cusize\u003e) {\n    // ...\n}\nfn test_hashmap(data: \u0026Vec\u003cusize\u003e) {\n    // ...\n}\n\nfn bench_group(mut runner: InputGroup\u003cVec\u003cusize\u003e\u003e) {\n    runner\n        // Trashes the CPU cache between runs\n        .add_plugin(CacheTrasher::default())\n        // Set the peak mem allocator. This will enable peak memory reporting.\n        .add_plugin(PeakAllocPlugin::new(GLOBAL))\n        // Enables the perf integration. Only on Linux, noop on other OS.\n        .add_plugin(PerfCounterPlugin::default());\n    // Enables throughput reporting\n    runner.throughput(|input| input.len() * std::mem::size_of::\u003cusize\u003e());\n    runner.register(\"vec\", |data| {\n        let vec = black_box(test_vec(data));\n        // The return value of the function will be reported as the `OutputValue` \n        vec.len() as u64\n    });\n    runner.register(\"hashmap\", move |data| {\n        let map = black_box(test_hashmap(data));\n        // The return value of the function will be reported as the `OutputValue` \n        map.len() as u64 * (std::mem::size_of::\u003cusize\u003e() + std::mem::size_of::\u003ci32\u003e()) as u64\n    });\n    runner.run();\n\n}\n\nfn main() {\n    // Tuples of name and data for the inputs\n    let data = vec![\n        (\n            \"max id 100; 100 ids all the same\",\n            std::iter::repeat(100).take(100).collect(),\n        ),\n        (\"max id 100; 100 ids all different\", (0..100).collect()),\n    ];\n    bench_group(InputGroup::new_with_inputs(data));\n}\n\n```\n\n### Example Output\n```bash\ncargo bench\n\nturbo_buckets_vs_fxhashmap_full_unique\n100k max id / 100k num elem\nTurboBuckets           Memory: 786.4 KB     Avg: 2.1107 GiB/s (+0.19%)    Median: 2.1288 GiB/s (+0.69%)    [1.9055 GiB/s .. 2.1464 GiB/s]    \nFxHashMap              Memory: 1.8 MB       Avg: 1.1116 GiB/s (-0.65%)    Median: 1.1179 GiB/s (-0.90%)    [1020.2 MiB/s .. 1.1363 GiB/s]    \n500k max id / 500k num elem\nTurboBuckets           Memory: 2.4 MB       Avg: 5.7073 GiB/s (-0.29%)    Median: 5.7633 GiB/s (-0.55%)    [5.1313 GiB/s .. 6.1104 GiB/s]    \nFxHashMap              Memory: 14.2 MB      Avg: 521.50 MiB/s (-1.81%)    Median: 523.42 MiB/s (-1.75%)    [465.28 MiB/s .. 562.83 MiB/s]    \n1m max id / 1m num elem\nTurboBuckets           Memory: 4.5 MB       Avg: 6.2922 GiB/s (+5.48%)    Median: 6.3850 GiB/s (+6.56%)    [4.9580 GiB/s .. 6.7989 GiB/s]    \nFxHashMap              Memory: 28.3 MB      Avg: 403.52 MiB/s (+0.00%)    Median: 396.74 MiB/s (+0.97%)    [355.83 MiB/s .. 473.37 MiB/s]    \n```\n\n### Peak Memory\nTo activate peak memory reporting, you need to wrap your allocator with the PeakMemAlloc and enable the PeakMemAllocPlugin (see example above).\n\nWhile number of allocations are also interesting for performance analysis, peak memory will determine the memory requirements of the code.\n\n### Perf Integration\nPerf may run into limitations where all counters are reported as zero. https://github.com/jimblandy/perf-event/issues/2\nDisabling the NMI watchdog should help:\n\n`sudo sh -c \"echo '0' \u003e /proc/sys/kernel/nmi_watchdog\"`\n\n### TODO\n\n- [ ] Improve the reporter api. Currently the reporter gets preaggregated data.\n\n#### Maybe Later Features:\n* Charts\n* Auto comparison of Histograms (e.g. if a benchmark has several bands in which it operates, it would be nice to compare them)\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fpseitz%2Fbinggan","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fpseitz%2Fbinggan","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fpseitz%2Fbinggan/lists"}