Welp, a profiler is a program that tells you all kinds of useful tidbits about your program as it's run, including time spent in each function. However, if you want a quick and dirty solution:
Note that this isn't portable by any means, but I have yet to see it not work, and it serves it's purpose.Code:#include <stdio.h> #include <time.h> void long_function(void) { int i; for (i = 0; i < 10000000; i++) ; } int main(void) { clock_t start; start = clock(); long_function(); printf("%f\n", (double)(clock() - start) / CLOCKS_PER_SEC); return 0; }