Complete.Org: Mailing Lists: Archives: freeciv-dev: April 1999:
Re: [Freeciv-Dev] Some performance issues
Home

Re: [Freeciv-Dev] Some performance issues

[Top] [All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index] [Thread Index]
To: Rizos Sakellariou <rizos@xxxxxxxxxxx>
Cc: freeciv-dev@xxxxxxxxxxx
Subject: Re: [Freeciv-Dev] Some performance issues
From: Mitch Davis <mjd@xxxxxxxxxx>
Date: Sun, 18 Apr 1999 15:18:10 +1000

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 |

[Prev in Thread] Current Thread [Next in Thread]