COMP INDEX

COMP _ _ _ _ _ _ _ _ _ _ _ _ switch

When comp is on, any succeeding function definitions are compiled into a faster-running form. Default is off.

examples:

The following procedure finds Fibonacci numbers recurs ively. Create a new file ``refib" in your current directory with the following lines in it:

 

procedure refib(n);
   if fixp n and n >= 0 then
     if n <= 1 then 1
       else refib(n-1) + refib(n-2)
    else rederr "nonnegative integer only";

end;

Now load REDUCE and run the following:



on time; 

  Time: 100 ms 



in "refib"$ 

  Time: 0 ms 



 

  REFIB 



 

  Time: 260 ms 



 

  Time: 20 ms 



refib(80); 

  37889062373143906 



 

  Time: 14840 ms 



on comp; 

  Time: 80 ms 



in "refib"$ 

  Time: 20 ms 



 

  REFIB 



 

  Time: 640 ms 



refib(80); 

  37889062373143906 



 

  Time: 10940 ms

Note that the compiled procedure runs faster. Your time messages will differ depending upon which system you have. Compiled functions remain so for the duration of the REDUCE session, and are then lost. They must be recompiled if wanted in another session. With the switch time on as shown above, the CPU time used in executing the command is returned in milliseconds. Be careful not to leave comp on unless you want it, as it makes the processing of procedures much slower.