Hello, there are two different programs written in C ++. Both programs implement the same task, but in different ways. It is required to compare their performance (speed, memory usage). I ask you to explain to me how to do this.
3 answers
To determine and compare the speed of some part of the program, you need to measure the time of its execution. To achieve statistical accuracy, you need to insert this part into the cycle and do it many times. Time can be measured by standard methods, for example, the clock function. See the reference information for your compiler or development environment for details. In addition, there are methods for more accurate time measurement on different platforms.
You can insert meters into the program (if there are sources), or you can use external means.
If we are talking about Linux, then first you can look at the command GNU time (usually / usr / bin / time). Detailed information in the manpage ( for example here )
Run your programs with different data through it and compare the results.
I advise you to read Cormen - Algorithms. Construction and analysis.
If I am not mistaken, the first chapter is devoted specifically to this topic.
UPD: Like: "The author is the full name": Algorithms. Construction and analysis. 2nd Edition, download Thomas Kormen, Charles Lazerson, Ronald Rivest.
- Give the full name of the book, but rather a link to download. - username76