From ThirdMartini

[edit] Sebastian's Blog

Automatic Function Timer
Posted 00:16, 15 December 2009 by Seb

I have been playing around with some gcc attribute functionality recently ( Specifically the cleanup attribute ) and had an interesting idea. Often times I've needed to be able to time how long a function took to execute. I've done this in the past using a couple of custom functions and calling them at the start and finish of said function. But cleanup makes it a bit easier.

The sample code below creates a generic function timer, and all that is needed to use it is to add a TIME_FUNCTION; call after your variable definitions. The timing and reporting is taken care of for you.

(Read More)


Personal tools