Giter Site home page Giter Site logo

jadegeek / nanobench Goto Github PK

View Code? Open in Web Editor NEW

This project forked from martinus/nanobench

0.0 0.0 0.0 7.19 MB

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

Home Page: https://nanobench.ankerl.com

License: MIT License

Shell 7.51% C++ 82.27% Python 1.45% HTML 0.94% CMake 7.83%

nanobench's Introduction

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.

nanobench's People

Contributors

fferflo avatar lectem avatar martinus avatar pr8x avatar tridacnid avatar vadi2 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.