At work we used to use intel's v-tune for profiling purposes with visual c++ applications.

However, if you are only interested in how long a certain function runs you might as well just take the start and end time and substract start from end to get the runtime, for instance like this:

Qt Code:
  1. #include <iostream>
  2. #include <ctime>
  3.  
  4. using namespace std;
  5.  
  6. void myFunction()
  7. {
  8. int j = 0;
  9.  
  10. for (int i = 0; i < 1000000; ++i)
  11. {
  12. ++j;
  13. }
  14. }
  15.  
  16. void main(int argc, char** argv)
  17. {
  18. // start benchmarking
  19. double truntime=0.0, tstart;
  20. tstart = clock();
  21.  
  22. myFunction();
  23.  
  24. // end benchmarking
  25. truntime += clock() - tstart;
  26.  
  27. // rescale to seconds
  28. truntime /= CLOCKS_PER_SEC;
  29.  
  30. cout << "Runtime was: " << truntime << " seconds." << endl;
  31.  
  32. return 0;
  33. }
To copy to clipboard, switch view to plain text mode 

edit: wysota beat me