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
  • WorkOS - The modern identity platform for B2B SaaS
  • InfluxDB - Power Real-Time Data Analytics at Scale
  • SaaSHub - Software Alternatives and Reviews
  • benchmark

    A microbenchmark support library

  • coz

    Coz: Causal Profiling

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

  • WorkOS

    The modern identity platform for B2B SaaS. The APIs are flexible and easy-to-use, supporting authentication, user identity, and complex enterprise features like SSO and SCIM provisioning.

    WorkOS logo
  • 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