July 2015
Intermediate to advanced
558 pages
13h 31m
English
As programmers, we often need to measure performance of a section of code. While there are several excellent profiling tools available for this purpose, sometimes, being able to instrument our own code is both simple and more precise. The Boost Timer library provides an easy-to-use, portable interface for measuring the execution times and reporting them by instrumenting your code. It is a separately compiled library, not header-only, and internally uses Boost Chrono.
The
boost::timer::cpu_timer class is used to measure the execution time of a section of code. In the following example, we write a function that reads the contents of a file and returns it in a dynamic array wrapped in a unique_ptr ...
Read now
Unlock full access