Re: [Freeciv-Dev] Some performance issues
[Top] [All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index] [Thread Index]
Rizos Sakellariou wrote:
>
> Let me say here that multiplication is still an expensive operation on most
> modern processors with a cost that varies from 10 to 14 CPU cycles in many
> cases. Compilers are typically smart enough to convert multiplications of a
> variable by an integer to a series of ADDs and SHIFTs (thereby reducing
> the cost of a MUL), but they are left with no choice in the case of
> the multiplication of two unknowns as it is our case here. As a solution,
> i suggest to replace all occurrences of y*map.xsize with something like
> an array ymult[y] whose elements (from 0 to map.ysize) are precomputed
> at the beginning of each game.
Thanks for looking at this.
Having a lookup table is a good idea. We could either have a
table with a well-known name, or a function to do a lookup. On
compilers such as gcc, the function could be made inline.
Hmm, the table sounds neater...
Regards,
Mitch.
--
| mailto:mjd@xxxxxxxxxx | Not the official view of: |
| mailto:mjd@xxxxxxxxxxxxxxxx | Australian Calculator Opn |
| Certified Linux Evangelist! | Hewlett Packard Australia |
|
|