• Stars
    star
    1,282
  • Rank 35,206 (Top 0.8 %)
  • Language
    C++
  • License
    MIT License
  • Created over 4 years ago
  • Updated 8 months ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

Simple, fast, accurate single-header microbenchmarking functionality for C++11/14/17/20

ankerl::nanobench

ankerl::nanobench logo

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

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

#define ANKERL_NANOBENCH_IMPLEMENT
#include <nanobench.h>

int main() {
    double d = 1.0;
    ankerl::nanobench::Bench().run("some double ops", [&] {
        d += 1.0 / d;
        if (d > 5.0) {
            d -= 5.0;
        }
        ankerl::nanobench::doNotOptimizeAway(d);
    });
}

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 as

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

Documentation

Extensive documentation is available.

More

  • Code of Conduct - Contributor Covenant Code of Conduct
  • I need a better logo. Currently I use a small bench. Nanobench. Ha ha.

More Repositories

1

robin-hood-hashing

Fast & memory efficient hashtable based on robin hood hashing for C++11/14/17/20
C++
1,469
star
2

unordered_dense

A fast & densely stored hashmap and hashset based on robin-hood backward shift deletion
C++
683
star
3

map_benchmark

Comprehensive benchmarks of C++ maps
C++
280
star
4

svector

Compact SVO optimized vector for C++17 or higher
C++
90
star
5

BitcoinUtxoVisualizer

Visualize Bitcoin UTXO set
C++
41
star
6

programming-font-test-pattern

Test pattern for programming fonts
35
star
7

better-faster-stronger-mixer

Testing framework for the quest to find a fast & strong mixer, e. g for hashtables.
C++
34
star
8

differential-evolution-rs

Generic Differential Evolution for Rust
Rust
15
star
9

YaceReloaded

Yet Another Corewar Evolver - It's been 12 years, now I'll try my luck again.
Red
9
star
10

base58

A fast implementation of base58 encoding
C++
6
star
11

keto-calculator

keto calculator on the web
HTML
5
star
12

ninja2wctr

Calculates Wall Clock Time Responsibility for each output from .ninja_log
C++
4
star
13

cpp_rng

C++ implementation of random number generators
C++
4
star
14

java-playground

Lots of small java features
Java
3
star
15

exMARS

exMARS - Exhaust Memory Array Redcode Simulator
C
3
star
16

parallel_hashmap_benchmark

simple benchmark of parallel hash maps in C++
C++
3
star
17

bitcoin-utxo-visualizer-rs

Bitcoin UTXO Visualizer in Rust
Rust
3
star
18

bitcoin-stuff

Helpful script, documentation, etc for my bitcoin development
Ruby
3
star
19

gra

Git Repo Admin
Python
2
star
20

tacho

An experimental python tool to measure process runtimes
Python
2
star
21

Bench

Microbenchmark facility for C++. Very simple to use, single header only, with sound statistics.
C++
2
star
22

martinus.github.io

Build a beautiful and simple website in literally minutes. Demo at http://deanattali.com/beautiful-jekyll
HTML
1
star
23

brainwallet.rb

Ruby app for brainwallets
Ruby
1
star
24

wordle

C++
1
star
25

bunter

colorizes program output, making it 'bunter'
1
star
26

qmars

QMars stands for Quicker Mars. It is a completely new implementation of a mars simulator
C++
1
star
27

rust-ninja-progressbar

Progressbar for Ninja written in Rust
Rust
1
star