Git Product home page Git Product logo

minibench's Introduction

minibench

Tiny, zero-dependency, header-only microbenchmarking library for C.

Includes ministat code for stats.

Example (Linux)

This example shows speed difference for getting current cpuid between using (default) vdso call and forcing the transition to kernel mode by using explicit system call instruction.

$ make clean run
rm -f *.o *.out
cc -c example-linux.c -o example.o
cc example.o -o example-benchmark.out -lm
./example-benchmark.out

===== Running microbench =====
* system: Linux 5.15.0-56-generic x86_64
* resolution: 1ns
* iterations: 25
------------------------------
======= Ministat report ======
x vdso-getcpu (default)
+ syscall-getcpu
+--------------------------------------------------------------------------+
|                                                                   +      |
|                                                                   +      |
|                                                                   +      |
|                                                                   +      |
|                                                                   +      |
| x                                                                 +      |
| x     x                                                           +      |
| x     x                                                           +      |
| x     x                                                           +      |
| x     x                                                           +     +|
| x     x                                                           +     +|
| x     x                                                           +     +|
| x     x                                                           +     +|
| x     x                                                           +     +|
| x     x                                                           +     +|
| x     x                                                           +     +|
| x     x     x     x                                               +     +|
||____A_M_|                                                        |M_A__| |
+--------------------------------------------------------------------------+
    N           Min           Max        Median           Avg        Stddev
x  25            20            50            30          26.4     7.5718778
+  25           130           140           130         133.2     4.7609523
Difference at 95.0% confidence
        106.8 +/- 3.59739
        404.545% +/- 13.6265%
        (Student's t, pooled s = 6.32456)

Example (Darwin)

$ make clean run
rm -f *.o *.out
cc -c example-darwin.c -o example.o
cc example.o -o example-benchmark.out -lm
./example-benchmark.out

===== Running microbench =====
* system: Darwin 22.1.0 arm64
* resolution: 1000ns           
* iterations: 25           
------------------------------
======= Ministat report ======
x loop(1000)
+ loop(10000)
+--------------------------------------------------------------------------+
|x                                                                      +  |
|x                                                                      + +|
|x x                                                                    + +|
|x x                                                                    + +|
|x x                                                                    + +|
|x x                                                                    + +|
|x x                                                                    + +|
|x x                                                                    + +|
|x x                                                                    + +|
|x x                                                                    + +|
|x x                                                                    + +|
|x x                                                                    + +|
|x x                                                                    + +|
|MA|                                                                    MA||
+--------------------------------------------------------------------------+
    N           Min           Max        Median           Avg        Stddev
x  25          3000          4000          3000          3440     506.62281
+  25         34000         35000         34000         34480     509.90195
Difference at 95.0% confidence
	31040 +/- 289.099
	902.326% +/- 8.40405%
	(Student's t, pooled s = 508.265)

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.