[ https://issues.apache.org/jira/browse/MATH-650?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13090224#comment-13090224 ]
Sebb commented on MATH-650: --------------------------- Any change needs to bear in mind that the fields need to remain thread-safe, i.e. whatever generates them must publish the values safely to all threads. This is currently achieved by using the static{} block with final fields. Seems to me there are two possible approaches to fix this: - improve the performance of the existing code - change the code to use initialisation on demand, so only the required parts are intialised. Static holder classes can probably be used here to ensure safe publication. In the case of floor(), that does not need the calculated fields, so it would speed it up. Note that the FastMath version of floor() is likely to have similar performance to Math.floor(), as it's not an algorithm that benefits from (or indeed needs) the FastMath approach. It would be useful to have performance figures for more complicated calculations, where FastMath should start to show benefits. > 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