bobpellegrino
Well-known member
I had a (very incomplete) idea for a timing function. The goal would be to reduce some repetitive code when performance tuning.
Usually the profiling phase of my development includes many instances of:
To streamline this, I defined timeit():
So timeit(somefunc); actually works as expected. But now I'm stuck on two things:
Maybe it would be better to make it a macro instead.
Usually the profiling phase of my development includes many instances of:
Code:
elapsedMillis t1;
somefunc();
printf("somefunc took %d millis\n", t1);
To streamline this, I defined timeit():
Code:
void timeit(void (*function)()) {
elapsedMillis time;
(*function)();
printf("took %d\n", time);
}
So timeit(somefunc); actually works as expected. But now I'm stuck on two things:
- How do I do this if the timed function has arguments? timeit(somefunc(x)); does not work.
- How could I reference the name of the function as a string so that the timeit() function could print "somefunc() took x milliseconds"
Maybe it would be better to make it a macro instead.