Profilers are used to analyze a program, measuring, among others, the memory or time complexity of a program, and the frequency and duration of function calls. Profilers are useful because they allow you to see where the "slow" parts of your program are, and can help you optimize it.
A common tool to profile your code is valgrind's tool callgrind.
Callgrind can do a lot of things, but the basic usage is:
valgrind --tool=callgrind [program]
Watch out! Make sure you use a version of your program that has been compiled without any attempt of improving performance (i.e. the Debug version).
Callgrind typically generates an output file of the type "callgrind.out.xxxx". Open this using kcachegrind and then you will get a grapically overview of all functions, calls, and performance of your code. This way, it is very easy to track down, what is consuming so much memory/time.
Profilers are used to analyze a program, measuring, among others, the memory or time complexity of a program, and the frequency and duration of function calls. Profilers are useful because they allow you to see where the "slow" parts of your program are, and can help you optimize it.
A common tool to profile your code is valgrind's tool callgrind.
Callgrind can do a lot of things, but the basic usage is:
valgrind --tool=callgrind [program]
Watch out! Make sure you use a version of your program that has been compiled without any attempt of improving performance (i.e. the Debug version).
Callgrind typically generates an output file of the type "callgrind.out.xxxx". Open this using kcachegrind and then you will get a grapically overview of all functions, calls, and performance of your code. This way, it is very easy to track down, what is consuming so much memory/time.