I looked through old threads but could not find the answer to my question:
How can I time the body of my function inside a C program?
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
A simple method is to use the ‘clock’ function:
Or if you’re on linux you can use the ‘time’ command to time how long it takes your app to execute; this doesn’t allow you to time a specific code section though, and includes time taken to initiate the process etc.
Edit: This is very much a basic ‘hack-in-a-quick-timer’ approach. For true performance profiling you want to look at a proper profiler, as suggested by Larry Watanabe.