I'm writing a program that takes information from another file about a list of customers and calculates a bill according to pre-defined specifications, and I want to know if there is a command that calculates the number of loops a program does and displays it?Is there a command in the Programming code C that calculates how many number of loops a program does?
I don't know if I understood what you want, but what I'd do is define a counter variable and increment it by one each time the loop is executed.... then you display the value of the counter....Is there a command in the Programming code C that calculates how many number of loops a program does?
I don't know of a command, but it is easy to implement a counter.
Just declare an integer variable and then increment it inside the loop. When the loop is exited, display the value of the counter variable.
There is certainly no command in the language. You can set up your own counter in the loop, as others have suggested.
However, many C coding environments contain a profiler, which can do this. It is very useful in debugging and optimizing code to see where in the code the program spends most of its time.
Since profilers will vary on different systems I cannot describe exactly how to use it. It could be called something like ';trace';, or ';pprof';. On visual C++ it is available under the Build menu.
Subscribe to:
Post Comments (Atom)
c graphic programming sample codes
ReplyDeletec example 3D graphics in C