[
https://issues.apache.org/jira/browse/MATH-650?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13090294#comment-13090294
]
Luc Maisonobe commented on MATH-650:
------------------------------------
The problem is not specific to the floor method. In fact, the first call to any
method in FastMath loads the class and at class loading the static constant
tables are populated. This problem has already been identified some time ago (I
can't find the thread, but I think the example at that time was about the first
calls to FastMath.exp).
There are several places where we compute some initial constants or tables and
use them later. The computed constants are always the same, and in fact they
could be compile-time constants. I wonder if we should have some way to compute
these tables at compile time and have them simply loaded without recomputation.
The precomputed tables could be either literal doubles in automatically
generated java source code or they could be stored in some text files embedded
withing the jar.
The same problem occurs for the constants in the Legendre-Gauss integrator (we
could use higher degrees if we could store constants), for some ODE
integrators, for the Dfp class (in this case they are string literals with a
very large number of significant digits) ...
> FastMath has static code which slows the first access to FastMath
> -----------------------------------------------------------------
>
> Key: MATH-650
> URL: https://issues.apache.org/jira/browse/MATH-650
> Project: Commons Math
> Issue Type: Improvement
> Affects Versions: Nightly Builds
> Environment: Android 2.3 (Dalvik VM with JIT)
> Reporter: Alexis Robert
> Priority: Minor
>
> Working on an Android application using Orekit, I've discovered that a simple
> FastMath.floor() takes about 4 to 5 secs on a 1GHz Nexus One phone (only the
> first time it's called). I've launched the Android profiling tool (traceview)
> and the problem seems to be linked with the static portion of FastMath code
> named "// Initialize tables"
> The timing resulted in :
> - FastMath.slowexp (40.8%)
> - FastMath.expint (39.2%)
> \- FastMath.quadmult() (95.6% of expint)
> - FastMath.slowlog (18.2%)
> Hoping that would help
> Thanks!
> Alexis Robert
--
This message is automatically generated by JIRA.
For more information on JIRA, see: http://www.atlassian.com/software/jira