Issue 727: Using apifun can ruin performance

Reported by Michael Baudin, May 23, 2012

Using apifun can ruin performance.

This may happen in the case where the call to the apifun functions 
implies a interpretation cost which is larger than the cost of the 
algorithm itself. 
In the following script, we call a function 1000 times in two 
situations: with or without argument checking.

-->exec apifunperf.sce;
With checkargs: 8.87
Without checkargs: 0.03

It might be necessary to turn some apifun functions into C code 
(instead of the current macros-based implementation).

Comment 1 by Michael Baudin, Sep 8, 2012

Labels: Priority:High Priority:Medium

Comment 2 by John Gliksberg, Aug 7, 2015

In scilab 6, the performance loss is much lower:

(on my machine)

Scilab 6
with checkargs: 0.67
without checkargs: 0.14

Scilab 5
with checkargs: 1.96
without checkargs: 0.13

Furthermore, if JIT is successfully integrated into scilab,
this should reduce the loss even more.

The performance loss is consistent with the many
extra checks performed (even though the scilab code could
be optimized -- e.g. using type() instead of typeof()).

This issue should be marked as closed, or at least
de-prioritized to Medium/Low.

Created: 5 years 9 months ago by Michael Baudin

Updated: 2 years 7 months ago

Status: New

Followed by: 1 person