Page 1 of 1

Whats the least bad , memory or CPU overhead?

Posted: Mon Feb 28, 2011 8:39 am
by Peterbjornx
I am writing some utility routines at this moment and i was wondering, should i add a cache for results or should i just have it fetch the result every time?

Re: Whats the least bad , memory or CPU overhead?

Posted: Mon Feb 28, 2011 9:15 am
by Solar
...then think about if it's worth the bother to optimize the code, then optimize it, then measure the performance again (because you might have made it worse, or introduced less-maintainable code for a neglectible performance gain).

Hence the mantra of optimization: measure, optimize, measure.

Re: Whats the least bad , memory or CPU overhead?

Posted: Mon Feb 28, 2011 3:59 pm
by OSwhatever
An interesting question is how do you profile your code in your OS?

There are a lot of good tools for code performance profiling that will not work on a OS for scratch.

Re: Whats the least bad , memory or CPU overhead?

Posted: Mon Feb 28, 2011 9:16 pm
by madeofstaples
It depends, of course, on the realistic constraints of the particular project.

In theory, of course, space is more powerful than time.

Re: Whats the least bad , memory or CPU overhead?

Posted: Mon Feb 28, 2011 11:16 pm
by gravaera
Your project's hardware target has a lot of impact on which you trade off usually also. You can generally decide which path to take when you have to choose based on your own goals. "Must fit in 1.44MB" will obviously make you want to optimize more aggressively for space than for speed.

--All the best,
gravaera

Re: Whats the least bad , memory or CPU overhead?

Posted: Mon Mar 07, 2011 9:36 pm
by salil_bhagurkar
I use -finstrument-functions, and then output the function address and processor timestamp on each function entry and exit, on the serial port, which Qemu outputs to a file :mrgreen:
Then I externally parse this file to match each address with the linker map and print out a table for each function and its average time spent, and number of entries into it.

This gives me a fair idea of performance problems.