Sujet : Re: The old college try
De : rjh (at) *nospam* cpax.org.uk (Richard Heathfield)
Groupes : comp.theoryDate : 30. May 2025, 12:05:54
Autres entêtes
Organisation : Fix this later
Message-ID : <101c3ei$era6$1@dont-email.me>
References : 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30
User-Agent : Mozilla Thunderbird
On 30/05/2025 10:56, vallor wrote:
In the case I gave it, O(n) becomes O(1). It was
a "trick" I figured out on the Commodore PET in
the 80's: using the numeric keypad as an index
for arrays to add x/y values to compute a player's
movement in a rudimentary game I wrote. (In BASIC,
I'm ashamed to say. ;) The array computation replaced
a bunch of if-then statements, and it ran a lot faster
after that.
The time: 1989.
The date: Atari ST.
The program: ballistics.
Potential problem: trig functions are slow, right?
The optimisation: pre-calculate sine, cosine, and tangent lookup tables at the start of the program.
The result: slow to initialise, but acceptable speed thereafter.
The upgrade: remove the lookup table calcs and just call sin, cos etc when needed.
The result: blitzingly fast.
The lesson: premature optimisation is the root of all evil.
-- Richard HeathfieldEmail: rjh at cpax dot org dot uk"Usenet is a strange place" - dmr 29 July 1999Sig line 4 vacant - apply within