How to get the time cost of functions?

hi,
There is a shell including many functions, when I run ksh -x/-v to see the call sequence, but how do I know which function cost more?
Of course, use time CMD to get the scripts runnning time, while it can not tell me which cost more.
Thanks very much.

Well, you could do something like this:

if [ $TIME ]; then 
  PREFIX=time
else
  PREFIX=""
fi

$PREFIX myfunc arg1 arg2 arg3

$PREFIX myfunc2 arg1 arg2 arg3 | $PREFIX myfunc3 arg1