The goal of this exercise is to introduce you to the use of
std::chrono to do some basic performance measurements.
The test program includes manually inserted calls to
high_resolution_clock to retrieve the current time_point, which
allows to measure the elapsed time between two points.
Build and run
cputicks.cc:
cd esc15/hands-on/basic
c++ -std=c++14 -O -o cputicks cputicks.cc
./cputicks
Run the program a few times, possibly also with arguments:
./cputicks 100
./cputicks 1000
-
Why does
test1()report much more time spent thantest2()? -
Why do the times reported by
test1()fluctuate so much? -
Do the times change if you change the optimization level of the compilation (
-O0through-O3)?