Re: profilers

fjh@mundook.cs.mu.OZ.AU (Fergus Henderson)
10 Dec 1997 00:35:58 -0500

          From comp.compilers

Related articles
profilers Waverly@DigitSW.com (Waverly Edwards) (1997-12-05)
Re: profilers wi534@victoria.tc.ca (William A. Barath) (1997-12-07)
Re: profilers fjh@mundook.cs.mu.OZ.AU (1997-12-10)
Re: profilers bwm@bwmartin.demon.co.uk (Barry Martin) (1997-12-10)
Re: profilers adewitt@cs.cmu.edu (Tony DeWitt) (1997-12-10)
Re: profilers debray@CS.Arizona.EDU (1997-12-12)
Re: profilers cfc@world.std.com (Chris F Clark) (1997-12-12)
Re: profilers wi534@victoria.tc.canada (William A. Barath) (1997-12-12)
| List of all articles for this month |

From: fjh@mundook.cs.mu.OZ.AU (Fergus Henderson)
Newsgroups: comp.compilers
Date: 10 Dec 1997 00:35:58 -0500
Organization: Comp Sci, University of Melbourne
References: 97-12-017 97-12-046
Keywords: performance

"William A. Barath" <wi534@victoria.tc.ca> writes:


>The most efficient way I can imagine to do it is this: compile into
>each function a small code fragment at the entry and exit points which
>read a global variable containing the seed of a high-resolution timer
>and add the difference between the two reads to a table entry for that
>function. Easy, little overhead, little bloat, and accurate even if
>the timer is only good for milliseconds (due to the averaging effect
>of repeated updates.) I've never done it, but it seems quite
>reasonable.
>
>[That's what Unix C compilers do with the -p flag. -John]


Are you sure? I thought Unix C compilers inserted profiling code that
recorded execution *counts* for each function, but that for doing the
actual timing they used PC-sampling techiques based on the use of
`setitimer(ITIMER_PROF, ...)' to schedule regular `SIGPROF' signals.


The Mercury distribution includes (Mercury) source code for a profiler
that can do both flat (prof-style) and call-graph (gprof-style)
profiles of Mercury programs, using this technique. It's available
via <http://www.cs.mu.oz.au/mercury>.


The current version only does time profiling, but we've recently been
doing some work on adding support for profiling memory allocation. Of
course profiling the allocations is the easy bit; in an environment
with garbage-collection, more detailed memory profiling information is
very desirable. There's been some useful work on this done in the
functional programming language community in recent years (I can dig
up some references if needed).


--
Fergus Henderson <fjh@cs.mu.oz.au>
WWW: <http://www.cs.mu.oz.au/~fjh>
PGP: finger fjh@128.250.37.3
[You're right, Unix profiling counts procedure calls but does statistical
timing. You'd need to have a high-res timer readable in application
programs and can either lock out interrupts or do something to account
for the time they take. -John]




--


Post a followup to this message

Return to the comp.compilers page.
Search the comp.compilers archives again.