Skip to content

Latest commit

 

History

History
137 lines (99 loc) · 5.15 KB

index.rst

File metadata and controls

137 lines (99 loc) · 5.15 KB

nanobench

.. toctree::
   :maxdepth: 2
   :hidden:
   :caption: Getting Started

   tutorial


.. toctree::
   :maxdepth: 2
   :hidden:
   :caption: Comparison

   comparison


.. toctree::
   :maxdepth: 2
   :hidden:
   :caption: Reference

   reference
   genindex

.. toctree::
   :maxdepth: 2
   :hidden:
   :caption: About

   license
   CODE_OF_CONDUCT.md


Release License Travis CI Build Status Appveyor Build Status Join the chat at https://gitter.im/nanobench/community

I need a better logo. Currently I use a small bench. Nanobench. Ha ha.

ankerl::nanobench is a platform independent microbenchmarking library for C++11/14/17/20.

.. literalinclude:: code/full_example_simple.cpp
    :language: c++
    :linenos:


The whole executable runs for ~60ms and prints

|               ns/op |                op/s |    err% |          ins/op |          cyc/op |    IPC |         bra/op |   miss% |     total | benchmark
|--------------------:|--------------------:|--------:|----------------:|----------------:|-------:|---------------:|--------:|----------:|:----------
|                7.52 |      132,948,239.79 |    1.1% |            6.65 |           24.07 |  0.276 |           1.00 |    8.9% |      0.00 | `some double ops`

Which github renders like

ns/op op/s err% ins/op cyc/op IPC bra/op miss% total benchmark
7.52 132,948,239.79 1.1% 6.65 24.07 0.276 1.00 8.9% 0.00 some double ops

The benchmarked code takes 7.52 nanoseconds to run, so ~133 million times per seconds. Measurements fluctuate by 1.1%. On average 6.65 instructions are executed in 24.07 CPU cycles, resulting in 0.276 instructions per cycle. A single branch is in the code, which branch prediction missed in 8.9% of the cases. Total runtime of the benchmark with the name some double ops is 0.00, so just a few milliseconds.

Design Goals

Ease of use
Simple but powerful API, fast compile times, easy to integrate anywhere.
Fast
Get accurate results as fast as possible
Accurate
Get deterministic, repeatable, and accurate results that you can make sound decisions on.
Robust
Be robust against outliers, warn if results are not reliable.