In a program which I built for a university project, I have to evaluate its execution time in relation to the number of time it executes (the program is basically a for cycle). The number of cycles is passed as a command-line argument in the terminal.
As the title says, is there an easier way to produce an execution time log that looks like this (using the c++ fstream library maybe):
N of steps Time (s)
1 0
10 0.2
100 1
etc... etc...
Obviously, the dumb way to do it is:
- Run the code changing manually the number of cycles.
- Tabulating the N of steps and the user time as the process goes on (the shell (I use bash if I'm not mistaken) is
time <executable name> <N of cycles>
)
but for that, I have to repeat the process something like a thousand times, so i thought that an "automatic" logging should do the trick.
The question is: How can I implement that "automatic logging" in order to save precious time?