I am a C++ beginner and I have been working on a C++ question where I hope to look at how my algorithm is working. I want to be able to start and end a timer anywhere in the main method in a short and simple way if I wished (so that it doesn't really influence my function's CPU during timing). I hope to directly get the time in milliseconds. I know that in Python the time
library can solve the problem directly (by using the method in Appendix A), but I wonder if there is in C++. Is there a short and convenient method of doing that? Any help will be appreciated.
P.S. (1) My current C++ code is just translating Appendix A to C++. (2) I learned C++ by myself, so I haven't really seen many books about C++ programming yet. Thus, recommending internet resources about the library is great help for me such that I can use it in future programming.
Appendix A: Code snippet
Appendix A content (mentioned above) is shown as follows:
def func(): # Do something
import time
start = time.time()
func()
end = time.time()
print(f"Process completed in {end - start} milliseconds.")