| ??? 05/29/02 15:30 Read: times |
#23607 - RE: Performance improvement |
"If you have a lot of accessses to a particular slot in a struct, try to make a pointer to this entry."
This is not necessarily the case! If you access a struct member directly, eg fred.this.that.the_other, the compiler can work out the address at compile time - using a pointer could actually make it worse! As I've mentioned before, there is quite a widespread belief that pointers are inherently faster than indices for accessing array elements; this is not necessarily so; eg, see: http://www.keil.com/discuss/docs/thread1156.htm As I've also mentioned before, When performance is an issue, it is always important to check the generated assembler! If you use pointers in Keil, be sure to use memory-specific ones. Be sure to use unsigned char wherever possible - avoid int, and disable the ANSI Integer Promotion. If possible, have for loops counting down to zero, so that the DJNZ instruction can then be used. You can make a huge difference to both code size and speed by carefully considering where you place your variables - the ones used most often should go into the fastest memory area; eg, I once saved several K by simply moving a very widely used variable from XDATA to DATA! In Keil, use the Browser to sort your variables by number of references - then work on the most-frequently-used variables. You should also look carefully at the variables used within your most critical loops. Loop indexes are prime candidates for placing in DATA. Read the Appendix "Writing Optimum Code" in the C51 manual. |
| Topic | Author | Date |
| Performance Analyser in keil | 01/01/70 00:00 | |
| RE: Performance Analyser in keil | 01/01/70 00:00 | |
| RE: Performance Analyser in keil | 01/01/70 00:00 | |
| RE: Performance Analyser in keil | 01/01/70 00:00 | |
| RE: Performance Analyser in keil | 01/01/70 00:00 | |
| RE: Performance improvement | 01/01/70 00:00 | |
| RE: Performance improvement | 01/01/70 00:00 | |
| RE: Performance improvement | 01/01/70 00:00 | |
| RE: Performance improvement | 01/01/70 00:00 | |
| RE: To Andy | 01/01/70 00:00 | |
| RE: Performance Analyser in keil | 01/01/70 00:00 | |
| RE: Performance Analyser in keil | 01/01/70 00:00 | |
RE: To Andy | 01/01/70 00:00 |



