Step37: Measuring execution time

Measuring time – The easy way

When you program on A500 and you want your effect to run at full speed (means 50FPS), you often wonder how much time is taking your code. The easiest way to do this is to use « raster lines ». The principle is very easy. Before your routine start, you change background color to « red » for example, and when your routine end, you set it back to « black ». That means, everything that is red on your screen is the time taken to run your routine. If your routine is small then call it multiple time to have a more significative measure.

Here is an example:

On the following video, you can see a blue part in the background. You can see that the more things are drawn on screen, the more the blue part big.

This method is very rough and usually is enough to check execution time. You can also easily see if the optimisations you are doing are changing the execution time.

The advanced way

When working with copper, blitter and cpu you can also compute the execution time for each instruction. On internet, you can find the table of execution time for all instructions and you can know how much time instructions are taking. Instructions are measures in « cycles ». The cycle duration is related to the CPU frequency.

Here is a table for « MOVE » instruction :

This could be very useful for example for computing the maximum number of colors that you can change during one line. I prefer the easy way, but people are quite strong for computing this. But the execution time depends on what is currently happening in the DMA for example. Il the DMA bus is taken by « someone » then everything will be slowed a bit. So theorical measures can be a bit wrong.

For instance, when changing a color using the blitter, it take an amount of cycles, corresponding to 8 pixels (this is the theory). But if you have 5 bitplanes enable at that time, then everything is slower. So changing on color may take 12 pixels or more.

I also read about people using CIA timers, but I never tested this method.


Some nice tutorial on Scoopex YouTube channel :

Cool demos of that time

1991 Phenomena / enigma (march 1991)

The raytracing « snake » became very famous.

A french demo group recently did a demo with remake of that effect (and many others)

A l’ancienne by X-men (.fr) | 64k | Revision 2013

1991 Anarchy / lemmings (with Skid Row) (february 1991) Intro

Laisser un commentaire

Votre adresse de messagerie ne sera pas publiée. Les champs obligatoires sont indiqués avec *

Ce site utilise Akismet pour réduire les indésirables. En savoir plus sur comment les données de vos commentaires sont utilisées.