PostgreSQL 8.4 added a feature to allow track statistics on how long each database function written in PL/pgSQL and similar languages takes to execute. To enable this, edit your postgresql conf:
track_functions = all
The other option here is pl, which only tracks the pl/* language functions instead of all of them (that is, not the ones written in C). Once that's done, you've executed some functions, and you've waited a moment for those to show up in the statistics collector, the following query will show you what executed:
SELECT * FROM pg_stat_user_functions;
In earlier versions, it was possible to build your own test harness. If instead you'd like to figure out which individual statements are responsible for the overhead, ...