Tracking time inside a function call - c++

338 Views Asked by At

One of my functions is taking more time to execute than expected. It's one of nesteds function and these functions are spread in multiple files across a big project.

function1 (...) {
  function2 (...);
}

function2(...){
  function3(..)
}
...

I am thinking of a way to print time taken by each function call. I am not sure if it's a correct approach. eg:

function1: 1.0 ms
function2: 0.8 ms
function3: 0.1 ms 

Unfortunate I am stuck with an very old compiler gcc-4.1.2. Is there a possibility to trace the timing of all the functions involved in user space without too much modifications in the files (because it is a big project and functions are spread across multiple files). Or If there is a tutorial, please consider pointing me to the link.

Thanks

0

There are 0 best solutions below