[Date Prev][Date Next] [Chronological] [Thread] [Top]

[rtl] Integer Math instruction execution times





I've measured the typical execution times for various "C" math statements
on the SRA rtlinux data-system.   The system  is a 200mhz pentium,
64mb/ram, linux 2.0.29 with rtl-0.6.   The measurements were made by
measuring the time for 1000 operations using a Lecroy 9354a digital scope.
The code was executed in a Rtlinux "Task".



static int i,j,k,l;
Scope_on();
for ( i=0; i<1000; i++ ) {
  ;		           // 26.8us or 26.2ns/loop
}
Scope_off();

where the internal part of the loop was se to:

  action                      Measured time    Instruction time
---------------------------------------------------------------
  k = i * j;		  //  76.13us/loop  or 49.9ns/mpy

  k = i / 5;		  //  267.6us/loop  or 241ns/div

  k = i + j;		  //  31.13us/loop  or 4.33ns/add



The variables had to be declared static, or else the compiler was not
generating instructions for the action.  I discovered because the pulse
width on the scope was not changing when the action inside the loop was
changed.  In fact, the time was exactly the same no matter what was done
inside the loop!  Upon running gcc -O2 -S sra_irq.c and examining the
assembly source, I discovered that no code was generated for the action.
Once the involved variables were declared static, code was generated and
the scope reflected believable execution times.

for an empty loop, the gcc compiler generated a very tight loop of simply:

loop:
   dec  xxx
   jc loop


-Wayne



--- [rtl] ---
For more information on Real-Time Linux see:
http://rtlinux.cs.nmt.edu/