> I have used the Python's C-API to call some Python code in my c code and
> now I want to know how much time does my Python part of the program
> takes. I came across the PyEval_SetProfile API and am not sure how to
> use it. Do I need to write my own profiling function?
You could have a look at the source code of the cProfile extension
module. I assume it uses the feature.
In your case, what's wrong with simply measuring the time?
/* variables. */
unsigned long delta_usec;
struct timeval t1, t2;
/* if your Python code is called multiple times, do this for each one,
and (if you like) sum up the result. It's simpe enough, and you
don't have to mess with profiling function.
Alternatively, you could use a C profiler like Valgrind