Xref: news2.mv.net comp.os.msdos.djgpp:8333 From: "John M. Aldrich" Newsgroups: comp.os.msdos.djgpp Subject: Re: Profiling Date: Thu, 05 Sep 1996 20:12:36 -0700 Organization: Three pounds of chaos and a pinch of salt Lines: 47 Message-ID: <322F96A4.73A1@cs.com> References: NNTP-Posting-Host: ppp211.cs.com Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit To: Graham Sturmy DJ-Gateway: from newsgroup comp.os.msdos.djgpp Graham Sturmy wrote: > > Hi, I was wondering if there was a profiling utility for DJGPP (v2) > available. > > I want to be able to find out where my C program is spending most of its > time. (On my hard disk isn't really the answer I want!) > > Any help would be appreciated. Use the GNU profiler which comes with djgpp. It is called gprof. Detailed instructions for use are in the FAQ (v2/faq201b.zi); just search for "profiling" and you'll find it. Brief instructions: Compile AND link your program with the -pg switch. When you compile, be sure to create a plain image as well as a stubbed image. (Do this by typing 'gcc -pg -o myprog ...' instead of 'gcc -pg -o myprog.exe ...') Run your program. It will likely run a lot slower then usual; that is to be expected. Don't worry about this messing up the profiling data - it takes it into account. When your program is finished (it MUST exit normally!), it should dump a file called 'gmon.out' in the program directory. (If it doesn't, look in the FAQ for possible reasons why.) Now simply type 'gprof myprog' to get a full profiling dump. WARNING: This data can be extremely lengthy and I recommend you redirect it to a file! The dump contains all the information you should need to interpret the data. Also do not run gprof on the .exe file, as it will crash. If you have any problems with this and *cannot find a solution in the FAQ*, please post specific details (including the exact instructions you use to compile and any error messages you get) here and we'll try to help you more. :) John -- Anything that happens, happens. Anything that, in happening, causes something else to happen, causes something else to happen. Anything that, in happening, causes itself to happen again, happens again. It doesn't necessarily do it in chronological order, though. --- Douglas Adams