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

Re: profiling howto/info



On Thu, 26 Aug 1999, Erik wrote:

> Hi
> 
> Is there a good article/tutorial/howto to read up on profiling? I've seen
> profiling macros used in code before, but I'm not clear on the implementation.
> Thnx
> 
>         -Erik <br0ke@math.smsu.edu> [http://shells.clipboard.com/~br0ke]
> 
> The opinions expressed by me are not necessarily opinions. In all
> probability, they are random rambling, and to be ignored. Failure to ignore
> may result in severe boredom or confusion. Shake well before opening. Keep
> Refrigerated.
>         
> 

There are several ways to profile your program. The easiest and most obvious
is to use a profiler. Other ways is to write profiling functions and call them
when your program enters/leaves some important sections - like this:

int pf_draw;

void init_drawing_function()
{
	profiler_add_function("draw_stuff()", &pf_draw);
}

void draw_stuff()
{
	profiler_enter( pf_draw );

	// do stuff

	profiler_leave( pf_draw );
}


This is what I found in the Golgotha source (and recently also in the
WorldFoundry engine) and I think it's much better - before releasing a
'non-debug' version, I just replace the functions with empty macros OR
profiling support can be turned temporarily off, provided that the functions
check that when called...



Other ways to profile? Ummm.. how about

# time program



Tomas