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

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

Our great sponsors
  • InfluxDB - Build time-series-based applications quickly and at scale.
  • Zigi - The context switching struggle is real
  • Sonar - Write Clean C++ Code. Always.
  • Scout APM - Truly a developer’s best friend
  • benchmark

    A microbenchmark support library

  • coz

    Coz: Causal Profiling

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

  • InfluxDB

    Build time-series-based applications quickly and at scale.. InfluxDB is the Time Series Data Platform where developers build real-time applications for analytics, IoT and cloud-native services in less time with less code.

  • Kalman

    Kalman Filter for C++ (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