It kind of depends on what you are actually looking for. If you want the CPU time a process takes, you can always install some process accounting, and get the pacct file that has that time.
If you are trying to time a function of a program (different subject) then you need to use the library function "clock" - which reports the CPU time used (man 3p clock). To use it to time a (quick) function, you get the cpu time when you start, then call the function 100 times, get the CPU time again - subtract first from the second, divide by 100. Use different iterations depending on the rough time it takes the function to run.
Another and better reference should be "info clock".
Last edited by jpollard; 02-01-2013 at 03:48 PM.