How to use Google Benchmark for C++ programs

Опубликовано: 03 Август 2026
на канале: arisaif
20,130
406

I explain how to use Google Benchmark library to measure the runtime and benchmark your C++ code.

I show how to sweep the input parameters to your functions and see how the runtime changes. Also, I cover how to estimate the runtime complexity of an algorithm using this library and calculate the coefficient of the highest term in the runtime complexity expression in Bog-O notation.

As an example of benchmarking, I compare Binary Search algorithm to Ternary Search, Exponential Search and Multi Threaded Binary Search.

You can quickly set up and use Google benchmark by downloading my repo from here:

https://github.com/ourarash/cpp-template

Learn more about this repo at:    • How to use Google Benchmark for C++ programs  
-----------------------------------------------------
See my other videos on:
Bazel and unit tests with GTest:    • Bazel & Google Test in Visual Studio Code  
Debugging in Visual Studio Code for C++:    • Debugging C++ in Visual Studio Code using ...  
Visual Studio Code, Top Features:    • Visual Studio Code Top Features 2020  
-----------------------------------------------------
Installing Bazel: https://docs.bazel.build/versions/3.2...
More info on Google Benchmark Framework: https://github.com/google/benchmark
-----------------------------------------------------
Keep in touch with me:
  / ourarash  

I'm the founder of BitcoinCrazyness app, the Most Advanced Cryptocurrency mobile APP for alerts, Check it out:

http://www.bitcoincrazyness.com/