i have created a program in c++ that implements dijkstra's algorithm, and i would like to count how many operations the program makes, but i dont know how.

Here is my main code:
int main()
int counter =0;
dij d;




return 0;

can anyone help please?
thank you in advance

You have two options.
The obvious on is to add a counter to the class. This can be done several ways and then each method and submethod adds to the count.

The other (less common and normally less elegant) is to have each method return the number of operations it took. But in this case since you will have private methods etc. I think it will be easier to do option one.

You can even get a bit of object-orientated about it. You can have a derived class that is dij_with_counting, and use a virtual addOperation() , that is a no-op in the base class but does the counting in the derived class. But it is unlikely to be required or worth the effort, unless the code is going into a ibrary.
method that is a