How to measure basic primitive operations in C ++?

For a project, I have to measure the runtime of basic primitive operations in C ++ for the machine I use. It says the following:

Write a program that determines the values ​​of the synchronization parameters ( fetch , store, + , - , * , / , < , function call, function return, new , delete and [] ) for the machine on which it is running.

fetch and store :

 a = b + 1 

b and 1 β€œextracted” (and added along with + ) and stored in a .

I had never done anything like this before. Do I need to use the clock method to calculate uptime? Should the code I'm setting be complicated or simple? How many times should it be evaluated?

+5
source share
1 answer

I think this one might be useful. Personally, I would do a few loops with a different number of iterations (starting from Example 10 and ending with 100,000). Similar to comparing sorting methods.

Ofc, if you need a more sophisticated method, you can use the above performance hook.

+1
source

Source: https://habr.com/ru/post/1202370/


All Articles