C++ code profiler

This is a discussion on C++ code profiler within the C++ Programming forums, part of the General Programming Boards category; Hi, could anyone suggest a good c++ code profiler. I have been using a gprof but now i need something ...

  1. #1
    Registered User
    Join Date
    Jan 2011
    Posts
    170

    C++ code profiler

    Hi, could anyone suggest a good c++ code profiler. I have been using a gprof but now i need something more sensitive. something that can tell me within each function how much time is spend on a particular line of code.

    Is there anything out there that can do that?

    thnx

    baxy

  2. #2
    Algorithm Dissector iMalc's Avatar
    Join Date
    Dec 2005
    Location
    New Zealand
    Posts
    6,261
    Windows? Linux?

    I use "Very Sleepy" on Windows, which is a sampling-based profiler. Its very non-invasive, but wont catch everything with 100% accuracy.
    My homepage
    Advice: Take only as directed - If symptoms persist, please see your debugger

    Linus Torvalds: "But it clearly is the only right way. The fact that everybody else does it some other way only means that they are wrong"

  3. #3
    and the hat of wrongness Salem's Avatar
    Join Date
    Aug 2001
    Location
    The edge of the known universe
    Posts
    32,333
    What do you mean by "profile lines"?

    Code:
    void foo ( int n ) {
      for ( int i = 0 ; i < n ; i++ ) {
        printf("n=%d\n", i );
      }
    }
    The actual time executing a single loop iteration is minuscule compared to everything else going on.

    What might be more interesting is seeing that the loop was executed say 1000 times.
    If this is what you're really after, then try gcov
    If you dance barefoot on the broken glass of undefined behaviour, you've got to expect the occasional cut.
    If at first you don't succeed, try writing your phone number on the exam paper.
    I support http://www.ukip.org/ as the first necessary step to a free Europe.

  4. #4
    Captain Crash brewbuck's Avatar
    Join Date
    Mar 2007
    Location
    Portland, OR
    Posts
    7,158
    Quote Originally Posted by baxy View Post
    Hi, could anyone suggest a good c++ code profiler. I have been using a gprof but now i need something more sensitive. something that can tell me within each function how much time is spend on a particular line of code.
    gprof will profile lines if you pass the -l option.
    Code:
    //try
    //{
    	if (a) do { f( b); } while(1);
    	else   do { f(!b); } while(1);
    //}

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Profiler for C code
    By guess85 in forum C Programming
    Replies: 11
    Last Post: 02-09-2010, 11:27 AM
  2. Source code ... profiler?
    By Boxknife in forum C Programming
    Replies: 6
    Last Post: 06-04-2008, 11:11 AM
  3. Code profiler?
    By h3ro in forum Tech Board
    Replies: 5
    Last Post: 04-07-2008, 09:16 AM
  4. Visual C++.NET Profiler?
    By -leech- in forum Windows Programming
    Replies: 0
    Last Post: 01-18-2003, 07:55 PM
  5. Profiler for g++
    By SilentStrike in forum Linux Programming
    Replies: 5
    Last Post: 04-29-2002, 11:01 PM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21