{"id":13678006,"url":"https://github.com/martinus/nanobench","last_synced_at":"2025-10-24T06:10:31.296Z","repository":{"id":38184814,"uuid":"213074835","full_name":"martinus/nanobench","owner":"martinus","description":"Simple, fast, accurate single-header microbenchmarking functionality for C++11/14/17/20","archived":false,"fork":false,"pushed_at":"2024-10-06T07:15:00.000Z","size":7849,"stargazers_count":1519,"open_issues_count":26,"forks_count":87,"subscribers_count":20,"default_branch":"master","last_synced_at":"2025-04-12T13:57:36.369Z","etag":null,"topics":["benchmark","cpp","cpp11","header-only","microbenchmark","single-file","single-header","single-header-lib"],"latest_commit_sha":null,"homepage":"https://nanobench.ankerl.com","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/martinus.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":".github/FUNDING.yml","license":"LICENSE","code_of_conduct":"docs/CODE_OF_CONDUCT.html","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},"funding":{"github":["martinus"],"patreon":null,"open_collective":null,"ko_fi":null,"tidelift":null,"community_bridge":null,"liberapay":null,"issuehunt":null,"otechie":null,"lfx_crowdfunding":null,"custom":null}},"created_at":"2019-10-05T21:39:18.000Z","updated_at":"2025-04-11T12:12:49.000Z","dependencies_parsed_at":"2023-02-18T07:46:02.630Z","dependency_job_id":"866284f7-3992-450e-8dc1-7164baff0046","html_url":"https://github.com/martinus/nanobench","commit_stats":{"total_commits":441,"total_committers":15,"mean_commits":29.4,"dds":0.08616780045351469,"last_synced_commit":"e4327893194f06928012eb81cabc606c4e4791ac"},"previous_names":[],"tags_count":21,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/martinus%2Fnanobench","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/martinus%2Fnanobench/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/martinus%2Fnanobench/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/martinus%2Fnanobench/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/martinus","download_url":"https://codeload.github.com/martinus/nanobench/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":254364270,"owners_count":22058878,"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":["benchmark","cpp","cpp11","header-only","microbenchmark","single-file","single-header","single-header-lib"],"created_at":"2024-08-02T13:00:49.316Z","updated_at":"2025-10-24T06:10:31.199Z","avatar_url":"https://github.com/martinus.png","language":"C++","funding_links":["https://github.com/sponsors/martinus"],"categories":["Debug","C++","Benchmarks","Benchmarking","Libraries"],"sub_categories":["Benchmarking"],"readme":"\u003ca id=\"top\"\u003e\u003c/a\u003e\n# ankerl::nanobench\n\n![ankerl::nanobench logo](src/docs/nanobench-logo-small.svg)\n\n[![Release](https://img.shields.io/github/release/martinus/nanobench.svg)](https://github.com/martinus/nanobench/releases)\n[![GitHub license](https://img.shields.io/github/license/martinus/nanobench.svg)](https://raw.githubusercontent.com/martinus/nanobench/master/LICENSE)\n[![Travis CI Build Status](https://travis-ci.com/martinus/nanobench.svg?branch=master)](https://travis-ci.com/martinus/nanobench)\n[![Appveyor Build Status](https://ci.appveyor.com/api/projects/status/github/martinus/nanobench?branch=master\u0026svg=true)](https://ci.appveyor.com/project/martinus/nanobench)\n[![Join the chat at https://gitter.im/nanobench/community](https://badges.gitter.im/nanobench/community.svg)](https://gitter.im/nanobench/community?utm_source=badge\u0026utm_medium=badge\u0026utm_campaign=pr-badge\u0026utm_content=badge)\n\n`ankerl::nanobench` is a platform independent microbenchmarking library for C++11/14/17/20.\n\n```cpp\n#define ANKERL_NANOBENCH_IMPLEMENT\n#include \u003cnanobench.h\u003e\n\nint main() {\n    double d = 1.0;\n    ankerl::nanobench::Bench().run(\"some double ops\", [\u0026] {\n        d += 1.0 / d;\n        if (d \u003e 5.0) {\n            d -= 5.0;\n        }\n        ankerl::nanobench::doNotOptimizeAway(d);\n    });\n}\n```\n\nThe whole executable runs for ~60ms and prints\n\n```markdown\n|               ns/op |                op/s |    err% |          ins/op |          cyc/op |    IPC |         bra/op |   miss% |     total | benchmark\n|--------------------:|--------------------:|--------:|----------------:|----------------:|-------:|---------------:|--------:|----------:|:----------\n|                7.52 |      132,948,239.79 |    1.1% |            6.65 |           24.07 |  0.276 |           1.00 |    8.9% |      0.00 | `some double ops`\n```\n\nWhich github renders as\n\n|               ns/op |                op/s |    err% |          ins/op |          cyc/op |    IPC |         bra/op |   miss% |     total | benchmark\n|--------------------:|--------------------:|--------:|----------------:|----------------:|-------:|---------------:|--------:|----------:|:----------\n|                7.52 |      132,948,239.79 |    1.1% |            6.65 |           24.07 |  0.276 |           1.00 |    8.9% |      0.00 | `some double ops`\n\nThe benchmarked code takes **7.52** nanoseconds to run, so ~**133** million times per seconds. Measurements fluctuate by\n**1.1%**. On average **6.65** instructions are executed in **24.07** CPU cycles, resulting in **0.276** instructions per\ncycle. A **single** branch is in the code, which branch prediction missed in **8.9%** of the cases. Total runtime of\nthe benchmark with the name `some double ops` is **0.00**, so just a few milliseconds.\n\n# Design Goals\n\n* **Ease of use**: Simple \u0026 [powerful API](https://nanobench.ankerl.com/reference.html), fast compile times, [easy to integrate anywhere](https://nanobench.ankerl.com/tutorial.html#installation).\n* **Fast**: Get accurate results as fast as possible. nanobench is [~80 times faster than google benchmark](https://nanobench.ankerl.com/comparison.html#runtime).\n* **Accurate**: Get deterministic, repeatable, and accurate results that you can make sound decisions on.\n* **Robust**: Be robust against outliers, warn if results are not reliable.\n\n# Documentation\n\n[Extensive documentation is available](https://nanobench.ankerl.com).\n\n# More\n\n* [Code of Conduct](src/docs/CODE_OF_CONDUCT.md) - Contributor Covenant Code of Conduct\n* I need a better logo. Currently I use a small bench. Nanobench. Ha ha.\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmartinus%2Fnanobench","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fmartinus%2Fnanobench","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmartinus%2Fnanobench/lists"}