precise time measurement

C++11 introduced the chrono API, you can use to get nanoseconds : auto begin = std::chrono::high_resolution_clock::now(); // code to benchmark auto end = std::chrono::high_resolution_clock::now(); std::cout << std::chrono::duration_cast<std::chrono::nanoseconds>(end-begin).count() << “ns” << std::endl; For a more relevant value it is good to run the function several times and compute the average : auto begin = std::chrono::high_resolution_clock::now(); uint32_t … Read more