Best accurate way to measure/compare elapsed time in C++

This page summarizes the projects mentioned and recommended in the original post on /r/cpp

Our great sponsors
  • benchmark

    A microbenchmark support library

  • coz

    Coz: Causal Profiling

    https://github.com/plasma-umass/coz https://youtu.be/7g1Acy5eGbE

  • JetBrains Dev Survey

    What’s up with the C++ ecosystem in 2023? JetBrains Developer Ecosystem Survey 2023 has given us many interesting insights. The Embedded (37%) and Games (39%) industries are already working with C++20, developers are incorporating static analysis in their CI, and ChatGPT usage among coders is flourishing. Read on for more!

  • Kalman

    Kalman Filter (by FrancoisCarouge)

    I use it with boilerplate similar to this: https://github.com/FrancoisCarouge/Kalman/blob/develop/benchmark/benchmark.cpp and run the executables with priority and pining: nice -n 20 tasker -- cpu-list 0

  • hyperfine

    A command-line benchmarking tool

    I have used hyperfine in the past, a rust CLI based tool to measure performance. you'd have to make some small changes, since hyperfine will measure the entire binary and not just parts of it, but it comes with some useful functions like warmup runs, graphical output and statistical analysis across multiple runs.

  • perfstat

    Python program for measuring performance statistics

    Perfstat - Performance statistics

  • nanobench

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

    Of course, the best way to benchmark is nanobench: https://nanobench.ankerl.com/

NOTE: The number of mentions on this list indicates mentions on common posts plus user suggested alternatives. Hence, a higher number means a more popular project.

Suggest a related project

Related posts