swarm-support
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: How To Profile A Program


From: Darren Schreiber
Subject: Re: How To Profile A Program
Date: Wed, 12 Apr 2000 22:21:03 -0700

The steps you provide are very clear.  I am going to give it a try when I
get over a couple of hurdles this week.  But, I'm still a bit unclear as to
what one learns by profiling.

        Darren


>Darren Schreiber wrote:
>>
>> Thanks for the help Marcus.  I haven't gotten to sit down with that code
>> since that version went up.  I am planning to return to work on it this
>> summer.  So, your pointers are a good head start.  I do think there are
>> some serious questions as to why the messages go to nil.  I found that this
>> happened usually a number of iterations into the model, and at the time
>> didn't have time to track them down.
>>
>> I do wonder if the more experienced developers could offer their
>> suggestions on what to do in order to clean code.  Obviously, you want to
>> remove unneeded variables and add comments to explain things better.
>>
>> But, I have to admit I've never learned how to:
>>
>> 1.  "profile" a program -- I've seen people use this term here and am not
>> sure I know precisely what it means.
>> 2.  check for memory leaks -- I believe I have one in my most recent
>> Schelling model, but don't know how to find them
>> 3.  figure out where the biggest slow downs in the program are -- (I think
>> this is what profiling can help with, right?)
>> 4.  think systematically about how to improve code
>
>>
>Agreed. Somebody just has to do the work of writing it down :)
>
>To use profiling, the GNU program called gprof must be installed.  I see
>it is in the Swarm-2.1 distribution for windows and it is installed by
>default in most unix/linux systems I've seen.  My RedHat system says
>gprof comes from the binutils package.
>
>To build a profile, you compile your programs with the -pg compiler
>flag. The way this is done in Swarm has changed now and then, but
>currently you can get it with
>
>make EXTRAOBJCFLAGS=-pg EXTRALDFLAGS=-pg
>
>Then after you run your program a while--long enough for it to build up
>some stats on it--you stop it and you should see a new file called
>"gmon.out".
>
>The gprof command produces a readable interpretation of the gmon.out
>file.
>In unix systems, the swarm executable is in that hidden directory .lib,
>so you tell the gprof program to use that, as in:
>
>gprof .lib/program-name-here
>
>In windows, you do not need the .lib directory in there.
>
>It will whir by on the screen quickly, but you can always ">" it into a
>file or pipe to less, "| less"
>
>
>As for the question of optimization, I can't say there are many general
>rules.  I've been nagging people for them for a long time, and the best
>answer I get is "don't write programs that waste time".  Don't
>recaculate things if you can save results and reuse them is a common
>tidbit.  However, one of the authors of XFree86 recently told me this is
>subject to qualification.  Since the CPU is faster than RAM access, it
>may save time to recalcuate than to store something large.
>
>--
>Paul E. Johnson                                email: address@hidden
>Dept. of Political Science
>       http://lark.cc.ukans.edu/~pauljohn
>University of Kansas                           Office: (785) 864-9086
>Lawrence, Kansas 66045                         FAX: (785) 864-5700
>
>                  ==================================
>   Swarm-Support is for discussion of the technical details of the day
>   to day usage of Swarm.  For list administration needs (esp.
>   [un]subscribing), please send a message to <address@hidden>
>   with "help" in the body of the message.


_____________________________________________

                 Darren Schreiber
                  Attorney at Law
                 Graduate Student
             Political Science, UCLA
                address@hidden
        http://www.bol.ucla.edu/~dschreib

                  ==================================
   Swarm-Support is for discussion of the technical details of the day
   to day usage of Swarm.  For list administration needs (esp.
   [un]subscribing), please send a message to <address@hidden>
   with "help" in the body of the message.



reply via email to

[Prev in Thread] Current Thread [Next in Thread]