How it works...
Besides the pure test support, the testing package also provides the mechanisms for measuring the code performance. For this purpose, the B struct pointer as the argument is used, and the benchmarking functions in the test file are named as BenchmarkXXXX.
The essential part of the benchmark function is the manipulation with the timer and usage of the loop iteration counter N.
As you can see, the timer is manipulated with the methods, Reset/Start/StopTimer. By these, the result of the benchmark is influenced. Note that the timer starts running with the beginning of the benchmark function and the ResetTimer function just restarts it.
The N field of B is the iteration count within the measurement loop. The N value is set to ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access